private void PlayVideo(object sender, TappedRoutedEventArgs e) { Grid newGrid = (Grid)sender; FileProper fp = (FileProper)newGrid.Tag; VideoPlayer.Source = MediaSource.CreateFromStorageFile(fp.StorageFile); VideoPlayer.MediaPlayer.Play(); }
private async void PlayMedia(object sender, TappedRoutedEventArgs e) { Grid newGrid = (Grid)sender; FileProper fp = (FileProper)newGrid.Tag; StorageItemThumbnail thum = await fp.StorageFile.GetThumbnailAsync(ThumbnailMode.MusicView, 400); if (thum != null && thum.Type == ThumbnailType.Image) { var source = new BitmapImage(); source.SetSource(thum); imgThumFile.Source = ImageBrush.ImageSource = source; } tbTitle.Text = fp.Title; tbAlbum.Text = fp.Album; tbArtist.Text = fp.Artist; MediaPlayer.Source = MediaSource.CreateFromStorageFile(fp.StorageFile); MediaPlayer.MediaPlayer.Play(); }
async private System.Threading.Tasks.Task SetLocalMedia() { var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); //openPicker.FileTypeFilter.Add(".wmv"); //openPicker.FileTypeFilter.Add(".mp4"); //openPicker.FileTypeFilter.Add(".wma"); openPicker.FileTypeFilter.Add(".mp3"); openPicker.FileTypeFilter.Add(".flac"); var file = await openPicker.PickMultipleFilesAsync(); foreach (StorageFile i in file) { MusicProperties mp = await i.Properties.GetMusicPropertiesAsync(); FileProper fp = new FileProper { Album = mp.Album, AlbumArtist = mp.AlbumArtist, Artist = mp.Artist, Duration = mp.Duration, Publisher = mp.Publisher, Rating = (int)mp.Rating, StorageFile = i, Subtitle = mp.Subtitle, Name = i.Name, Title = mp.Title, TrackNumber = (int)mp.TrackNumber, Year = (int)mp.Year }; listFiles.Add(fp); } lvShowFile.ItemsSource = listFiles; }
async private System.Threading.Tasks.Task SetLocalVideo() { var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); openPicker.FileTypeFilter.Add(".wmv"); openPicker.FileTypeFilter.Add(".mp4"); openPicker.FileTypeFilter.Add(".wma"); var file = await openPicker.PickMultipleFilesAsync(); foreach (StorageFile i in file) { MusicProperties mp = await i.Properties.GetMusicPropertiesAsync(); FileProper fp = new FileProper { StorageFile = i, Name = i.Name }; listVideos.Add(fp); } lvShowVideo.ItemsSource = listVideos; }