/// <summary> /// When the Play button is pressed, this is run to play the media. /// </summary> /// <param name="sender">Where the call comes from.</param> /// <param name="e">The information about the click.</param> private void btnPlayMedia_Click(object sender, RoutedEventArgs e) { Button clickedButton = (Button)sender; NBMediaDataItem mediaData = (NBMediaDataItem)clickedButton.DataContext; PlayMediasArgs args = new PlayMediasArgs(this, mediaData.MediaSource); PlayMediaCommand playMediaCommand = new PlayMediaCommand(); if (playMediaCommand.CanExecute(args)) { playMediaCommand.Execute(args); } }
/// <summary> /// When you are coming to this page. This loads the cached data. /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { PlayMediasArgs playArgs = e.Parameter as PlayMediasArgs; // Did you come to this page to play something new? currentMediaPlayer = new MediaPlayer(); currentMediaPlayer.Source = (playArgs == null) ? NBPlayerState.CurrentPlaylist : null; medPlayer.SetMediaPlayer(currentMediaPlayer); if (playArgs != null) { loadSource(playArgs.Medias); // If so, load the new source. } else { loadPlayerState(); // Otherwise, continue playing the current source. } base.OnNavigatedTo(e); // Actually navigate to this page. }