private static MediaPickerController SetupController(MediaPickerDelegate mpDelegate, UIImagePickerControllerSourceType sourceType, string mediaType, MediaStorageOptions options = null) { var picker = new MediaPickerController(mpDelegate); picker.MediaTypes = new[] { mediaType }; picker.SourceType = sourceType; if (sourceType == UIImagePickerControllerSourceType.Camera) { picker.CameraDevice = GetUICameraDevice((options as CameraMediaStorageOptions).DefaultCamera); if (mediaType == TypeImage) { picker.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo; } else if (mediaType == TypeMovie) { VideoMediaStorageOptions voptions = (VideoMediaStorageOptions)options; picker.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Video; picker.VideoQuality = GetQuailty(voptions.Quality); picker.VideoMaximumDuration = voptions.DesiredLength.TotalSeconds; } } return(picker); }
/// <summary> /// Selects the video asynchronous. /// </summary> /// <param name="options">The options.</param> /// <returns>Task<IMediaFile>.</returns> /// <exception cref="NotSupportedException"></exception> public Task <MediaFile> SelectVideoAsync(VideoMediaStorageOptions options) { if (!IsPhotosSupported) { throw new NotSupportedException(); } return(GetMediaAsync(UIImagePickerControllerSourceType.PhotoLibrary, TypeMovie)); }
private async Task TakeNewVideo() { string msg = string.Empty; try { if (_mediaPicker == null) { var device = Resolver.Resolve <IDevice>(); ////RM: hack for working on windows phone? _mediaPicker = DependencyService.Get <IMediaPicker>() ?? device.MediaPicker; } VideoMediaStorageOptions options = new VideoMediaStorageOptions() { DefaultCamera = CameraDevice.Rear, Quality = VideoQuality.Medium, DesiredLength = TimeSpan.FromSeconds(20), SaveMediaOnCapture = true }; await _mediaPicker.TakeVideoAsync(options).ContinueWith(t => { if (t.IsFaulted) { msg = t.Exception.InnerException.ToString(); } else if (t.IsCanceled) { msg = "Cancelled"; } else { var mediaFile = t.Result; if (mediaFile != null) { LabelResult.Text = "File saved: " + mediaFile.Path; } else { msg = "The video failed to save. Please make sure the device has enough storage and try again."; } } }, TaskScheduler.FromCurrentSynchronizationContext()); } catch (Exception x) { msg = x.Message; } if (!String.IsNullOrEmpty(msg)) { await DisplayAlert("Failed", msg, "OK"); } }
/// <summary> /// Takes the video asynchronous. /// </summary> /// <param name="options">The options.</param> /// <returns>Task with a return type of MediaFile.</returns> /// <exception cref="System.NotSupportedException">Throws an exception if feature is not supported.</exception> public Task <MediaFile> TakeVideoAsync(VideoMediaStorageOptions options) { if (!IsCameraAvailable) { throw new NotSupportedException(); } options.VerifyOptions(); return(TakeMediaAsync("video/*", MediaStore.ActionVideoCapture, options)); }
/// <summary> /// Selects the video asynchronous. /// </summary> /// <param name="options">Video storage options.</param> /// <returns>Task with a return type of MediaFile.</returns> /// <exception cref="System.NotSupportedException">Throws an exception if feature is not supported.</exception> public Task <MediaFile> SelectVideoAsync(VideoMediaStorageOptions options) { if (!IsCameraAvailable) { throw new NotSupportedException(); } options.VerifyOptions(); return(TakeMediaAsync("video/*", Intent.ActionPick, options)); }
/// <summary> /// Takes the video asynchronous. /// </summary> /// <param name="options">The options.</param> /// <returns>Task<IMediaFile>.</returns> /// <exception cref="NotSupportedException"> /// </exception> public Task <MediaFile> TakeVideoAsync(VideoMediaStorageOptions options) { if (!IsVideosSupported) { throw new NotSupportedException(); } if (!IsCameraAvailable) { throw new NotSupportedException(); } //VerifyCameraOptions (options); return(GetMediaAsync(UIImagePickerControllerSourceType.Camera, TypeMovie, options)); }
/// <summary> /// Takes the video asynchronous. /// </summary> /// <param name="options">The options.</param> /// <returns>Task<IMediaFile>.</returns> /// <exception cref="NotImplementedException"></exception> /// <exception cref="System.NotImplementedException"></exception> public Task <MediaFile> TakeVideoAsync(VideoMediaStorageOptions options) { throw new NotImplementedException(); }