/// <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);
        }
Exemplo n.º 2
0
 public void PlayPath(string path, Microsoft.MediaCenter.MediaType asType, bool addToQueue)
 {
     try
     {
         if (!AddInHost.Current.MediaCenterEnvironment.PlayMedia(asType, path, addToQueue))
         {
             Logger.ReportInfo("PlayMedia returned false");
         }
     }
     catch (Exception ex)
     {
         Logger.ReportException("Playing media failed.", ex);
         Application.ReportBrokenEnvironment();
         return;
     }
 }
        private void QueuePlayableItemLegacy(PlayableItem playable)
        {
            Microsoft.MediaCenter.MediaType type = MediaType.Audio;

            bool success = true;

            foreach (string file in playable.FilesFormattedForPlayer)
            {
                if (!PlaybackControllerHelper.CallPlayMedia(AddInHost.Current.MediaCenterEnvironment, type, file, true))
                {
                    success = false;
                    break;
                }
            }

            if (!success)
            {
                OnErrorPlayingItem(playable, "PlayMedia returned false");
            }
        }
Exemplo n.º 4
0
        public static bool CallPlayMedia(MediaCenterEnvironment mediaCenterEnvironment, Microsoft.MediaCenter.MediaType type, object media, bool queue)
        {
            string file = media.ToString();

            Logger.ReportVerbose("Calling MediaCenterEnvironment.PlayMedia: " + file);
            return(mediaCenterEnvironment.PlayMedia(type, media, queue));
        }
 public static bool CallPlayMedia(MediaCenterEnvironment mediaCenterEnvironment, Microsoft.MediaCenter.MediaType type, object media, bool queue)
 {
     Logger.ReportVerbose("Calling MediaCenterEnvironment.PlayMedia");
     return(mediaCenterEnvironment.PlayMedia(type, media, queue));
 }