public async void GetSong() { StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation; // lấy folder lúc cài đặt app folder = await folder.GetFolderAsync("Assets"); // trỏ đến thư mục Assets // StorageFile file = await folder.GetFileAsync("music.mp3");// lấy file trong thư mục assets StorageFile file = await folder.GetFileAsync("video.mp4");// lấy file trong thư mục assets MediaPlay.SetSource(await file.OpenAsync(FileAccessMode.Read), file.ContentType); }
private async void Image_PointerPressed(object sender, PointerRoutedEventArgs e) { FileOpenPicker fopvideo = new FileOpenPicker(); fopvideo.SuggestedStartLocation = PickerLocationId.Desktop; fopvideo.FileTypeFilter.Add(".mp4"); fopvideo.FileTypeFilter.Add(".ogg"); fopvideo.FileTypeFilter.Add(".wmv"); StorageFile file = await fopvideo.PickSingleFileAsync(); IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read); MediaPlay.SetSource(stream, file.ContentType); MediaPlay.Play(); }