Pick from Gallery

Use the UM_Application.GalleryService entry point for picking images from the drive storage.  Make sure that gallery service is enabled inside the Plugin Editor UI.

Once you've activated the platforms you interested in, you may use Gallery API, as described with the code samples below.

You can also configure the picker option before stating the picker UI.

Pick an Image

using SA.CrossPlatform.App;
...

var gallery = UM_Application.GalleryService;

int maxThumbnailSize = 1024;
gallery.PickImage(maxThumbnailSize, (result) => {
    if (result.IsSucceeded) {
        UM_Media media = result.Media;

        Texture2D image = media.Thumbnail;
        Debug.Log("Thumbnail width: " + image.width + " / height: " + image.height);
        Debug.Log("mdeia.Type: " + media.Type);
        Debug.Log("mdeia.Path: " + media.Path);
    } else {
        Debug.Log("failed to pick an image: " + result.Error.FullMessage);
    }
});

You may wonder what the maxThumbnailSize parameter does and why you might need it. The reason is the following. Use may have a huge photos/images on the device, and you probably do not want whole 4k or 8k photo to be transferred to your application since the transfer processes can take a while + it will result in a noticeable memory usage spike. 

That's why you can set the max image size. If the user will pick an image that is bigger then maxThumbnailSize parameter value. The plugin will resize an image on a native part, saving image format and dimensions of course. 

Pick a Video

The approach is similar. You will have the same result object, the Thumbnail of the result will be the Thumbnail of the captured video. And you can get actual video using the media Path property. See the example below:

using SA.CrossPlatform.App;
...

var gallery = UM_Application.GalleryService;

int maxThumbnailSize = 1024;
gallery.PickVideo(maxThumbnailSize, (result) => {
    if (result.IsSucceeded) {
        UM_Media media = result.Media;

        Texture2D image = media.Thumbnail;
        Debug.Log("Thumbnail width: " + image.width + " / height: " + image.height);
        Debug.Log("mdeia.Type: " + media.Type);
        Debug.Log("mdeia.Path: " + media.Path);
    } else {
        Debug.Log("failed to pick an image: " + result.Error.FullMessage);
    }
});

Once a video is picked, you may read a video file and for example, upload it to your server, or use it in any other way you want since you have access to picked video file. See the example below how to fully read picker video file content. See the example below:

using System.IO;
using SA.CrossPlatform.App;
...

var gallery = UM_Application.GalleryService;

int maxThumbnailSize = 1024;
gallery.PickVideo(maxThumbnailSize, (result) => {
    if (result.IsSucceeded) {
        UM_Media media = result.Media;
        byte[] movieBytes = File.ReadAllBytes(media.Path);
        Debug.Log("movie size bytes: " + movieBytes.Length);
    } else {
        Debug.Log("failed to pick an image: " + result.Error.FullMessage);
    }
});

Or you can also play picked video using the native player.

using System.IO;
using SA.CrossPlatform.App;
using SA.CrossPlatform.Media;
...

var gallery = UM_Application.GalleryService;

int maxThumbnailSize = 1024;
gallery.PickVideo(maxThumbnailSize, (result) => {
    if (result.IsSucceeded) {
        UM_Media media = result.Media;
        UM_MediaPlayer.ShowRemoteVideo(media.Path, () => {
            Debug.Log("Video closed");
        });
    } else {
        Debug.Log("failed to pick an image: " + result.Error.FullMessage);
    }
});