public void StopIfOutOfScope(BaseItem item)
        {
            if (!IsPlaying)
            {
                return;
            }

            //if the passed in item is our current scope or our current scope is a parent then we are still in scope and continue playing
            if (item != CurrentScope && !IsParent(CurrentScope, item))
            {
                PlaybackControllerHelper.Stop();
            }
        }
Exemple #2
0
 /// <summary>
 /// Stops playback
 /// </summary>
 protected override void StopInternal()
 {
     PlaybackControllerHelper.Stop();
 }
        private void PlayInternal(BaseItem item)
        {
            if (!item.ThemesLoaded)
            {
                item.LoadThemes();
            }

            var coll = new MediaCollection();

            if (item.ThemeVideos != null && item.ThemeVideos.Count > 0)
            {
                for (var i = 0; i < Config.Instance.ThemeBackgroundRepeat; i++)
                {
                    item.ThemeVideos.ForEach(v => coll.AddItem(v.Path));
                }

                IsPlayingVideo = true;
            }

            else if (item.ThemeSongs != null && item.ThemeSongs.Count > 0)
            {
                for (var i = 0; i < Config.Instance.ThemeBackgroundRepeat; i++)
                {
                    item.ThemeSongs.ForEach(a => coll.AddItem(a.Path));
                }

                IsPlayingVideo = false;
            }
            else if (Config.Instance.PlayTrailerAsBackground)
            {
                var movie = item as Movie;
                if (movie != null && movie.TrailerFiles.Any())
                {
                    for (var i = 0; i < Config.Instance.ThemeBackgroundRepeat; i++)
                    {
                        foreach (var trailerFile in movie.TrailerFiles)
                        {
                            coll.AddItem(trailerFile);
                        }
                    }

                    IsPlayingVideo = true;
                }
            }

            if (coll.Any())
            {
                Application.UIDeferredInvokeIfRequired(() =>
                {
                    //stop anything currently playing
                    PlaybackControllerHelper.Stop();

                    var mce              = Application.MediaCenterEnvironment;
                    mce.PropertyChanged += EnvironmentPropertyChange;

                    if (mce.PlayMedia(MediaType.MediaCollection, coll, false))
                    {
                        IsPlaying = true;
                        Application.CurrentInstance.ShowNowPlaying = IsPlayingVideo;
                        CurrentScope = item;
                    }
                    else
                    {
                        mce.PropertyChanged -= EnvironmentPropertyChange;
                    }
                });
            }
        }