/// <summary> /// Handles a change of Playstate by firing various events and post play processes /// </summary> private void HandleStoppedState(MediaCenterEnvironment env, MediaExperience exp, MediaTransport transport, PlaybackStateEventArgs e) { // Stop listening to the events env.PropertyChanged -= MediaCenterEnvironment_PropertyChanged; transport.PropertyChanged -= MediaTransport_PropertyChanged; // This will prevent us from getting in here twice after playback stops and calling post-play processes more than once. _HasStartedPlaying = false; _CurrentMediaCollection = null; var mediaType = exp.MediaType; // Check if internal wmc player is still playing, which could happen if the user launches live tv while playing something if (mediaType != Microsoft.MediaCenter.Extensibility.MediaType.TV) { Application.CurrentInstance.ShowNowPlaying = false; if (mediaType == Microsoft.MediaCenter.Extensibility.MediaType.Audio || mediaType == Microsoft.MediaCenter.Extensibility.MediaType.DVD) { PlaybackControllerHelper.ReturnToApplication(true); } } // Fire the OnFinished event for each item OnPlaybackFinished(e); }
/// <summary> /// Handles a change of Playstate by firing various events and post play processes /// </summary> private void HandleStoppedState(MediaCenterEnvironment env, MediaExperience exp, MediaTransport transport, PlaybackStateEventArgs e) { Logger.ReportVerbose("In HandleStoppedState"); // Stop listening to the events env.PropertyChanged -= MediaCenterEnvironment_PropertyChanged; transport.PropertyChanged -= MediaTransport_PropertyChanged; Logger.ReportVerbose("Events unhooked"); // This will prevent us from getting in here twice after playback stops and calling post-play processes more than once. _HasStartedPlaying = false; CurrentMediaCollection = null; var mediaType = exp.MediaType; // Check if internal wmc player is still playing, which could happen if the user launches live tv while playing something if (mediaType != Microsoft.MediaCenter.Extensibility.MediaType.TV) { Logger.ReportVerbose("Turning off NPV"); Application.CurrentInstance.ShowNowPlaying = false; if (mediaType == Microsoft.MediaCenter.Extensibility.MediaType.Audio || mediaType == Microsoft.MediaCenter.Extensibility.MediaType.DVD) { PlaybackControllerHelper.ReturnToApplication(true); } } else { Logger.ReportVerbose("Not turning off NPV because Live TV is playing."); } Helper.AllowSleep(); // Fire the OnFinished event for each item Async.Queue(Async.ThreadPoolName.PlaybackFinished, () => OnPlaybackFinished(e)); }