/// <summary> /// Puts the player into fullscreen mode /// </summary> public override void GoToFullScreen() { var mce = MediaExperience ?? PlaybackControllerHelper.GetMediaExperienceUsingReflection(); if (mce != null) { Logger.ReportVerbose("Going fullscreen..."); mce.GoToFullScreen(); } else { Logger.ReportError("AddInHost.Current.MediaCenterEnvironment.MediaExperience is null, we have no way to go full screen!"); AddInHost.Current.MediaCenterEnvironment.Dialog(Application.CurrentInstance.StringData("CannotMaximizeDial"), "", Microsoft.MediaCenter.DialogButtons.Ok, 0, true); } }
/// <summary> /// Plays or queues Media /// </summary> protected virtual void PlayPlayableItem(PlayableItem playable) { this.Playable = playable; _HasStartedPlaying = false; // Get this now since we'll be using it frequently MediaCenterEnvironment mediaCenterEnvironment = AddInHost.Current.MediaCenterEnvironment; try { // Attach event handler to MediaCenterEnvironment // We need this because if you press stop on a dvd menu without ever playing, Transport.PropertyChanged will never fire mediaCenterEnvironment.PropertyChanged -= MediaCenterEnvironment_PropertyChanged; mediaCenterEnvironment.PropertyChanged += MediaCenterEnvironment_PropertyChanged; if (!CallPlayMediaForPlayableItem(mediaCenterEnvironment, playable)) { mediaCenterEnvironment.PropertyChanged -= MediaCenterEnvironment_PropertyChanged; OnErrorPlayingItem(playable, "PlayMedia returned false"); return; } MediaExperience exp = mediaCenterEnvironment.MediaExperience ?? PlaybackControllerHelper.GetMediaExperienceUsingReflection(); if (exp != null) { MediaTransport transport = exp.Transport; if (transport != null) { transport.PropertyChanged -= MediaTransport_PropertyChanged; transport.PropertyChanged += MediaTransport_PropertyChanged; // If using the legacy api we have to resume manually if (_CurrentMediaCollection == null) { long startPosition = playable.StartPositionTicks; if (startPosition > 0) { TimeSpan startPos = TimeSpan.FromTicks(startPosition); Logger.ReportVerbose("Seeking to " + startPos.ToString()); transport.Position = startPos; } } } else { Logger.ReportWarning("PlayPlayableItem: MediaTransport is null"); } if (playable.GoFullScreen) { Logger.ReportVerbose("Going fullscreen"); exp.GoToFullScreen(); } } else { Logger.ReportWarning("PlayPlayableItem: MediaExperience is null"); } } catch (Exception ex) { OnErrorPlayingItem(playable, ex); } }