/// <summary> /// Calls PlayMedia /// </summary> private bool CallPlayMediaLegacy(MediaCenterEnvironment mediaCenterEnvironment, PlayableItem playable) { Microsoft.MediaCenter.MediaType type = PlaybackControllerHelper.GetMediaType(playable); bool playedWithPlaylist = false; // Need to create a playlist if (PlaybackControllerHelper.RequiresWPL(playable)) { IEnumerable <string> files = playable.FilesFormattedForPlayer; string playlistFile = PlaybackControllerHelper.CreateWPLPlaylist(playable.Id.ToString(), files, playable.StartPlaylistPosition); if (!PlaybackControllerHelper.CallPlayMedia(mediaCenterEnvironment, type, playlistFile, false)) { return(false); } playedWithPlaylist = true; } // If we're playing a dvd and the last item played was a MediaCollection, we need to make sure the MediaCollection has // fully cleared out of the player or there will be quirks such as ff/rew remote buttons not working if (playable.HasMediaItems) { Video video = playable.MediaItems.First() as Video; Microsoft.MediaCenter.Extensibility.MediaType lastMediaType = PlaybackControllerHelper.GetCurrentMediaType(); if (video != null && video.MediaType == Library.MediaType.DVD && (lastMediaType == Microsoft.MediaCenter.Extensibility.MediaType.MediaCollection || lastMediaType == Microsoft.MediaCenter.Extensibility.MediaType.Unknown)) { System.Threading.Thread.Sleep(500); } } if (!playedWithPlaylist) { bool queue = false; foreach (string fileToPlay in playable.FilesFormattedForPlayer) { if (!PlaybackControllerHelper.CallPlayMedia(mediaCenterEnvironment, type, fileToPlay, queue)) { return(false); } queue = true; } } return(true); }
public static PlayState GetCurrentPlayState() { MediaExperience mce = Application.MediaExperience; // Try to access MediaExperience.Transport and get PlayState from there if (mce != null) { try { MediaTransport transport = mce.Transport; if (transport != null) { return(transport.PlayState); } } catch (InvalidOperationException ex) { // We may not have access to the Transport if another application is playing media Logger.ReportException("GetCurrentPlayState", ex); } // If we weren't able to access MediaExperience.Transport, it's likely due to another application playing media Microsoft.MediaCenter.Extensibility.MediaType mediaType = mce.MediaType; if (mediaType != Microsoft.MediaCenter.Extensibility.MediaType.Unknown) { Logger.ReportVerbose("MediaExperience.MediaType is {0}. Assume content is playing.", mediaType); return(Microsoft.MediaCenter.PlayState.Playing); } } // At this point nothing worked, so return Undefined return(PlayState.Undefined); }