I am trying to import a video into a UWP canvas. I have this code that successfully imports a picture: private async void AddImageButton_Click(object sender, RoutedEventArgs e) { Image MyImage = new Image();
var picker = new FileOpenPicker();
picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
picker.FileTypeFilter.Add(".jpg");
picker.FileTypeFilter.Add(".png");
StorageFile file = await picker.PickSingleFileAsync();
if (file != null)
{
StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", file);
// var files = await file.GetFilesAsync();
var bitmap = new BitmapImage();
var stream = await file.OpenReadAsync();
// AddHandler(, new ExceptionRoutedEventHandler(Bitmap_ImageFailed), true);
bitmap.ImageFailed += Bitmap_ImageFailed;
await bitmap.SetSourceAsync(stream);
MyImage.Source = bitmap;
AddHandler(ManipulationStartedEvent, new ManipulationStartedEventHandler(Image_ManipulationStarted), true);
AddHandler(ManipulationDeltaEvent, new ManipulationDeltaEventHandler(Image_ManipulationDelta), true);
AddHandler(ManipulationCompletedEvent, new ManipulationCompletedEventHandler(Image_ManipulationCompleted), true);
ManipulationMode = ManipulationModes.All;
MyImage.RenderTransform = ImageTransforms;
parentCanvas.Children.Add(MyImage);
}
}
I tried adapting this to import a video but got stuck when converting the bitmap to a MediaPlayerElement. Any suggestions?
Thanks!