private async void PlayNewSong_MediaEnded(MediaPlayer sender, object args) { timer.Change(Timeout.Infinite, Timeout.Infinite); bool isPlayingPlaylistTrack = playingMode == PlayingMode.PLAYLIST; MusicPlayerController.ReinitiatePlayer(ref player); player.MediaEnded += PlayNewSong_MediaEnded; if (isPlayingPlaylistTrack) { currentPlayingSongPlaylistIndex++; SetCurrentPlayingSong(playlistTracks, currentPlayingSongPlaylistIndex); } else { currentPlayingSongMusicLibraryIndex++; SetCurrentPlayingSong(musicLibrary, currentPlayingSongMusicLibraryIndex); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { dataGrid.SelectedIndex = isPlayingPlaylistTrack ? currentPlayingSongPlaylistIndex : currentPlayingSongMusicLibraryIndex; timelineSlider.Value = 0; } ); await MusicPlayerController.PlayAsync(player); UpdateTimelineSlider(); }
private async void PlaySongFromGrid_DoubleClick(object sender, DoubleTappedRoutedEventArgs ev) { string paths = ((Song)dataGrid.SelectedItem).Path; StorageFile file = await StorageFile.GetFileFromPathAsync(paths); MusicPlayerController.ReinitiatePlayer(ref player); player.MediaEnded += PlayNewSong_MediaEnded; MusicPlayerController.SelectNewSource(player, file); await MusicPlayerController.PlayAsync(player); SetCurrentPlayingSongIndex(); timelineSlider.Value = 0; timelineSlider.ManipulationCompleted += SeekPositionSlider_ManipulationCompleted; UpdateTimelineSlider(); }
private async void PlaySongFromGrid_DoubleClick(object sender, DoubleTappedRoutedEventArgs ev) { string paths = ((Song)dataGrid.SelectedItem).Path; StorageFile file = await StorageFile.GetFileFromPathAsync(paths); MusicPlayerController.ReinitiatePlayer(ref player); player.MediaEnded += PlayNewSong_MediaEnded; await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() => { MusicPlayerController.SelectNewSource(player, file); await MusicPlayerController.PlayAsync(player); } ); SetCurrentPlayingSongIndex(); timelineSlider.Value = 0; timelineSlider.ManipulationCompleted += SeekPositionSlider_ManipulationCompleted; UpdateTimelineSlider(); }
private async void Continue_playing(object sender, RoutedEventArgs e) { UpdateTimelineSlider(); await MusicPlayerController.PlayAsync(player); }