Exemplo n.º 1
0
        internal void Play()
        {
            if (Microsoft.MediaCenter.UI.Application.ApplicationThread != System.Threading.Thread.CurrentThread)
            {
                Application.UIDeferredInvokeIfRequired(() => Play());
                return;
            }
            System.Diagnostics.Debug.Assert(Microsoft.MediaCenter.UI.Application.ApplicationThread == Thread.CurrentThread);
            Prepare();

            if (!MediaItems.Any() && !Files.Any())
            {
                Microsoft.MediaCenter.MediaCenterEnvironment ev = Application.MediaCenterEnvironment;
                ev.Dialog(Application.CurrentInstance.StringData("NoContentDial"), Application.CurrentInstance.StringData("Playstr"), Microsoft.MediaCenter.DialogButtons.Ok, 500, true);
                return;
            }
            if (CurrentMedia != null)
            {
                Logger.ReportInfo(string.Format("{0} about to play {1}({2}) ", PlaybackController.ControllerName, DisplayName, CurrentMedia.Files.FirstOrDefault()));
            }

            // If the controller already has active playable items, stop it and wait for it to flush out
            if (!QueueItem)
            {
                PlaybackController.StopAndWait();
            }

            // Run all pre-play processes
            RunPrePlayProcesses();

            if (!QueueItem && StopAllPlaybackBeforePlaying)
            {
                StopAllApplicationPlayback();
            }

            if (UseAutoPlay)
            {
                Logger.ReportVerbose("Playing with autoplay. Marking watched since we have no way of getting status on this.");

                MarkWatchedIfNeeded();
            }
            else
            {
                //AdjustRefreshRate();
                PlaybackController.Play(this);
            }
        }
Exemplo n.º 2
0
        internal void Play()
        {
            Prepare();

            if (!HasMediaItems && !Files.Any())
            {
                Microsoft.MediaCenter.MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
                ev.Dialog(Application.CurrentInstance.StringData("NoContentDial"), Application.CurrentInstance.StringData("Playstr"), Microsoft.MediaCenter.DialogButtons.Ok, 500, true);
                return;
            }

            Logger.ReportInfo(PlaybackController.ControllerName + " about to play " + DisplayName);

            // If the controller already has active playable items, stop it and wait for it to flush out
            if (!QueueItem)
            {
                PlaybackController.StopAndWait();
            }

            // Run all pre-play processes
            RunPrePlayProcesses();

            if (!QueueItem && StopAllPlaybackBeforePlaying)
            {
                StopAllApplicationPlayback();
            }

            if (UseAutoPlay)
            {
                Logger.ReportVerbose("Playing with autoplay. Marking watched since we have no way of getting status on this.");

                MarkWatchedIfNeeded();
            }
            else
            {
                PlaybackController.Play(this);
            }
        }
        internal void Play()
        {
            Prepare();

            if (!MediaItems.Any() && !Files.Any())
            {
                Microsoft.MediaCenter.MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
                ev.Dialog(Application.CurrentInstance.StringData("NoContentDial"), Application.CurrentInstance.StringData("Playstr"), Microsoft.MediaCenter.DialogButtons.Ok, 500, true);
                return;
            }
            if (CurrentMedia != null)
            {
                Logger.ReportInfo(string.Format("{0} about to play {1}({2}) ", PlaybackController.ControllerName, DisplayName, CurrentMedia.Files.FirstOrDefault()));
            }

            // If the controller already has active playable items, stop it and wait for it to flush out
            if (!QueueItem)
            {
                PlaybackController.StopAndWait();
            }

            // Run all pre-play processes
            RunPrePlayProcesses();

            if (!QueueItem && StopAllPlaybackBeforePlaying)
            {
                StopAllApplicationPlayback();
            }

            // Play Intros if specified
            if (PlayIntros && HasMediaItems)
            {
                var item = MediaItems.First();
                if (item is Movie && (item.DisplayMediaType == null || !item.DisplayMediaType.Equals("trailer", StringComparison.OrdinalIgnoreCase)))
                {
                    // Get intros for this item
                    var introItems = Kernel.Instance.MB3ApiRepository.RetrieveIntros(MediaItems.First().ApiId).OfType <Video>().ToList();
                    var intros     = introItems.Select(i => i.Files.FirstOrDefault()).ToList();

                    // Kick off our intro playback controller
                    if (intros.Any())
                    {
                        Application.CurrentInstance.IntroController.Init(intros);
                        Application.CurrentInstance.IntroController.Play();
                        //mark them watched
                        Async.Queue("Mark watched", () => { foreach (var i in introItems)
                                                            {
                                                                Kernel.ApiClient.UpdatePlayedStatus(i.ApiId, Kernel.CurrentUser.Id, true);
                                                            }
                                    });
                    }
                }
            }

            if (UseAutoPlay)
            {
                Logger.ReportVerbose("Playing with autoplay. Marking watched since we have no way of getting status on this.");

                MarkWatchedIfNeeded();
            }
            else
            {
                PlaybackController.Play(this);
            }
        }