async public void ChangeSource() { var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); openPicker.FileTypeFilter.Add(".wmv"); openPicker.FileTypeFilter.Add(".mp4"); openPicker.FileTypeFilter.Add(".wma"); openPicker.FileTypeFilter.Add(".mp3"); file = await openPicker.PickSingleFileAsync(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.Desktop; // video1 is a MediaElement defined in XAML if (null != file) { var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); Video1.SetSource(stream, file.ContentType); Songinfo.Text = file.DisplayName; Video1.Play(); } }
private async void NextSong() { x++; var file = playlist[x]; if (file == null) { x = 0; file = playlist[x]; var properties = await file.Properties.GetMusicPropertiesAsync(); if (file != null) { var stream = await file.OpenAsync(FileAccessMode.Read); Songinfo.Text = file.DisplayName; // mediaControl is a MediaElement defined in XAML Video1.SetSource(stream, file.ContentType); } } else { var properties = await file.Properties.GetMusicPropertiesAsync(); if (file != null) { var stream = await file.OpenAsync(FileAccessMode.Read); Songinfo.Text = file.DisplayName; // mediaControl is a MediaElement defined in XAML Video1.SetSource(stream, file.ContentType); } } }
async private void Previous1Song_Click(object sender, RoutedEventArgs e) { x--; if (x < 0) { x = 0; var file = playlist[x]; var properties = await file.Properties.GetMusicPropertiesAsync(); if (file != null) { var stream = await file.OpenAsync(FileAccessMode.Read); Songinfo.Text = file.DisplayName; // mediaControl is a MediaElement defined in XAML Video1.SetSource(stream, file.ContentType); } } else { var file = playlist[x]; var properties = await file.Properties.GetMusicPropertiesAsync(); if (file != null) { var stream = await file.OpenAsync(FileAccessMode.Read); Songinfo.Text = file.DisplayName; // mediaControl is a MediaElement defined in XAML Video1.SetSource(stream, file.ContentType); } } }
async private void AddSong_Click(object sender, RoutedEventArgs e) { var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); openPicker.FileTypeFilter.Add(".wmv"); openPicker.FileTypeFilter.Add(".mp4"); openPicker.FileTypeFilter.Add(".wma"); openPicker.FileTypeFilter.Add(".mp3"); StorageFile file = await openPicker.PickSingleFileAsync(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.Desktop; // video1 is a MediaElement defined in XAML if (null != file) { var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); playlist[i] = file; int b = i + 1; PlaylistSongs.Text += "\n" + b.ToString() + ") " + playlist[i].DisplayName; Songinfo.Text = file.DisplayName; // mediaControl is a MediaElement defined in XAML Video1.SetSource(stream, file.ContentType); i++; } }
async public void ChangeSource() { var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); openPicker.FileTypeFilter.Add(".wmv"); openPicker.FileTypeFilter.Add(".mp4"); openPicker.FileTypeFilter.Add(".wma"); openPicker.FileTypeFilter.Add(".mp3"); //file = await openPicker.PickSingleFileAsync(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.Desktop; var files = await openPicker.PickMultipleFilesAsync(); if (files.Count > 0) { // Application now has read/write access to the picked file(s) foreach (Windows.Storage.StorageFile file1 in files) { var stream = await file1.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); Video1.SetSource(stream, file1.ContentType); playlist[i] = file1; Songinfo.Text = file1.DisplayName; int n = i + 1; PlaylistSongs.Text += "\n" + n.ToString() + ") " + playlist[i].DisplayName; i++; } } else { Songinfo.Text = "Operation cancelled."; } // video1 is a MediaElement defined in XAML //if (null != file) //{ // var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); // Video1.SetSource(stream, file.ContentType); // playlist[i] = file; // Songinfo.Text = file.DisplayName; // PlaylistSongs.Text += "\n" + "1" + ") " + playlist[i].DisplayName; // i++; // Video1.Play(); //} }