/// <summary> /// Take a video with specified options /// </summary> /// <param name="options">Video Media Options</param> /// <returns>Media file of new video or null if canceled</returns> public async Task<MediaFile> TakeVideoAsync(StoreVideoOptions options) { if (!initialized) await Initialize(); if (!IsCameraAvailable) throw new NotSupportedException(); options.VerifyOptions(); var capture = new CameraCaptureUI(); capture.VideoSettings.MaxResolution = GetResolutionFromQuality(options.Quality); capture.VideoSettings.MaxDurationInSeconds = (float)options.DesiredLength.TotalSeconds; capture.VideoSettings.Format = CameraCaptureUIVideoFormat.Mp4; var result = await capture.CaptureFileAsync(CameraCaptureUIMode.Video); if (result == null) return null; string aPath = null; if (options?.SaveToAlbum ?? false) { try { string fileNameNoEx = Path.GetFileNameWithoutExtension(result.Path); var copy = await result.CopyAsync(KnownFolders.VideosLibrary, fileNameNoEx + result.FileType, NameCollisionOption.GenerateUniqueName); aPath = copy.Path; } catch (Exception ex) { Debug.WriteLine("unable to save to album:" + ex); } } return new MediaFile(result.Path, () => result.OpenStreamForReadAsync().Result, albumPath: aPath); }
/// <summary> /// Take a video with specified options /// </summary> /// <param name="options">Video Media Options</param> /// <returns>Media file of new video or null if canceled</returns> public async Task<MediaFile> TakeVideoAsync(StoreVideoOptions options) { if (!initialized) await Initialize(); if (!IsCameraAvailable) throw new NotSupportedException(); options.VerifyOptions(); var capture = new CameraCaptureUI(); capture.VideoSettings.MaxResolution = GetResolutionFromQuality(options.Quality); capture.VideoSettings.MaxDurationInSeconds = (float)options.DesiredLength.TotalSeconds; capture.VideoSettings.Format = CameraCaptureUIVideoFormat.Mp4; var result = await capture.CaptureFileAsync(CameraCaptureUIMode.Video); if (result == null) return null; return new MediaFile(result.Path, () => result.OpenStreamForReadAsync().Result); }