public bool IsSourceTypeAvailable(ISN_UIImagePickerControllerSourceType type) { #if UNITY_IPHONE return(_ISN_UI_IsSourceTypeAvailable((int)type)); #else return(true); #endif }
public List <string> GetAvailableMediaTypes(ISN_UIImagePickerControllerSourceType type) { #if UNITY_IPHONE string data = _ISN_UI_GetAvailableMediaTypesForSourceType((int)type); ISN_UIAvailableMediaTypes result = JsonUtility.FromJson <ISN_UIAvailableMediaTypes>(data); return(result.Types); #else return(new List <string>()); #endif }
internal static void CaptureMedia(int thumbnailSize, UM_MediaType type, ISN_UIImagePickerControllerSourceType source, Action <UM_MediaResult> callback) { ISN_UIImagePickerController picker = new ISN_UIImagePickerController(); picker.SourceType = source; switch (type) { case UM_MediaType.Image: picker.MediaTypes = new List <string>() { ISN_UIMediaType.IMAGE }; break; case UM_MediaType.Video: picker.MediaTypes = new List <string>() { ISN_UIMediaType.MOVIE }; break; } picker.MaxImageSize = thumbnailSize; picker.ImageCompressionFormat = ISN_UIImageCompressionFormat.JPEG; picker.ImageCompressionRate = 0.8f; UM_MediaResult pickResult; picker.Present((result) => { if (result.IsSucceeded) { UM_Media media = null; switch (result.MediaType) { case ISN_UIMediaType.IMAGE: media = new UM_Media(result.Image, result.ImageURL, UM_MediaType.Image); break; case ISN_UIMediaType.MOVIE: Texture2D img = ISN_AVAssetImageGenerator.CopyCGImageAtTime(result.OriginalMediaURL, 0); media = new UM_Media(img, result.MediaURL, UM_MediaType.Video); break; } pickResult = new UM_MediaResult(media); } else { pickResult = new UM_MediaResult(result.Error); } callback.Invoke(pickResult); }); }
private void StartPicker(ISN_UIImagePickerControllerSourceType sourceType, string mediaType) { ISN_UIImagePickerController picker = new ISN_UIImagePickerController { SourceType = sourceType, MediaTypes = new List <string>() { mediaType }, MaxImageSize = 512, ImageCompressionFormat = ISN_UIImageCompressionFormat.JPEG, ImageCompressionRate = 0.8f }; picker.Present(DisplayResult); }
/// <summary> /// Returns a Boolean value indicating whether the device supports picking media using the specified source type. /// Because a media source may not be present or may be unavailable, /// devices may not always support all source types. /// For example, if you attempt to pick an image from the user’s library and the library is empty, /// this method returns <c>false</c>. Similarly, if the camera is already in use, this method returns <c>false</c>. /// /// Before attempting to use an <see cref="ISN_UIImagePickerController"/> object to pick an image, /// you must call this method to ensure that the desired source type is available. /// </summary> /// <param name="sourceType">Source Type.</param> /// <returns></returns> public static bool IsSourceTypeAvailable(ISN_UIImagePickerControllerSourceType sourceType) { return(ISN_UILib.API.IsSourceTypeAvailable(sourceType)); }
/// <summary> /// Returns an array of the available media types for the specified source type. /// /// Some iOS devices support video recording. /// Use this method, along with the <see cref="IsSourceTypeAvailable"/> method, /// to determine if video recording is available on a device. /// </summary> /// <returns>The available media types.</returns> /// <param name="sourceType">The source to use to pick an image.</param> public static List <string> GetAvailableMediaTypes(ISN_UIImagePickerControllerSourceType sourceType) { return(ISN_UILib.API.GetAvailableMediaTypes(sourceType)); }