/// <inheritdoc /> public async Task <MediaFile> TakeVideoAsync(StoreVideoOptions options) { var capture = new CameraCaptureUI(); //capture.VideoSettings.MaxResolution = options.Quality.GetResolutionFromQuality(); //capture.VideoSettings.MaxDurationInSeconds = (float)options.DesiredLength.TotalSeconds; //capture.VideoSettings.Format = CameraCaptureUIVideoFormat.Mp4; var result = await capture.CaptureFileAsync(this.DeviceId); if (result == null) { return(null); } return(new MediaFile(result.Path, () => result.OpenStreamForReadAsync().Result)); }
/// <inheritdoc /> public async Task <MediaFile> TakePhotoAsync(StoreMediaOptions options) // TODO GATH: link from WindowsStore assembly { if (!this.IsEnabled) { throw new NotSupportedException(); } var capture = new CameraCaptureUI(); ////capture.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg; ////capture.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable; var result = await capture.CaptureFileAsync(this.deviceInformation.Id); if (result == null) { return(null); } StorageFolder rootFolder = ApplicationData.Current.LocalFolder; string targetFilePath = options.GetFilePath(rootFolder.Path); var directoryPath = Path.GetDirectoryName(targetFilePath); var directoryName = options.Directory; if (!string.IsNullOrWhiteSpace(directoryName)) { var exists = await FolderExistsAsync(rootFolder, directoryPath); if (!exists) { await rootFolder.CreateFolderAsync(directoryName, CreationCollisionOption.ReplaceExisting); } } rootFolder = await StorageFolder.GetFolderFromPathAsync(directoryPath); string targetFilename = Path.GetFileName(targetFilePath); var file = await result.CopyAsync(rootFolder, targetFilename, NameCollisionOption.ReplaceExisting).AsTask().ConfigureAwait(false); Stream stream = await file.OpenStreamForReadAsync().ConfigureAwait(false); return(new MediaFile(file.Path, () => stream)); }
/// <inheritdoc /> public async Task <MediaFile> TakePhotoAsync(StoreMediaOptions options) { if (!this.IsEnabled) { throw new NotSupportedException(); } var capture = new CameraCaptureUI(); capture.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg; capture.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable; var result = await capture.CaptureFileAsync(CameraCaptureUIMode.Photo); if (result == null) { return(null); } StorageFolder folder = ApplicationData.Current.LocalFolder; string path = options.GetFilePath(folder.Path); var directoryFull = Path.GetDirectoryName(path); var newFolder = directoryFull.Replace(folder.Path, string.Empty); if (!string.IsNullOrWhiteSpace(newFolder)) { await folder.CreateFolderAsync(newFolder, CreationCollisionOption.OpenIfExists); } folder = await StorageFolder.GetFolderFromPathAsync(directoryFull); string filename = Path.GetFileName(path); var file = await result.CopyAsync(folder, filename, NameCollisionOption.GenerateUniqueName).AsTask(); return(new MediaFile(file.Path, () => file.OpenStreamForReadAsync().Result)); }