internal void OnProgress(BasePlaybackController controller, PlaybackStateEventArgs args)
        {
            CurrentFileIndex = args.CurrentFileIndex;
            CurrentMediaIndex = args.CurrentMediaIndex;

            PlayState = PlayableItemPlayState.Playing;

            UpdateCurrentMediaPlayState(controller, args);

            if (_Progress != null)
            {
                try
                {
                    _Progress(this, new GenericEventArgs<PlayableItem>() { Item = this });
                }
                catch (Exception ex)
                {
                    Logger.ReportException("PlayableItem Progress event listener had an error: ", ex);
                }
            } 
        }
Exemplo n.º 2
0
        /// <summary>
        /// Goes through each Media object within PlayableMediaItems and updates Playstate for each individually
        /// </summary>
        private void UpdatePlayStates(BasePlaybackController controller, PlaybackStateEventArgs args)
        {
            string currentFile = CurrentFile;

            for (int i = 0; i < MediaItems.Count(); i++)
            {
                Media media = MediaItems.ElementAt(i);

                bool isCurrentMedia = i == CurrentMediaIndex;

                long currentPositionTicks = 0;
                int currentPlaylistPosition = 0;

                if (isCurrentMedia)
                {
                    // If this is where playback is, update position and playlist
                    currentPlaylistPosition = controller.GetPlayableFiles(media).ToList().IndexOf(currentFile);
                    currentPositionTicks = args.Position;
                }

                Application.CurrentInstance.UpdatePlayState(media, media.PlaybackStatus, currentPlaylistPosition, currentPositionTicks, args.DurationFromPlayer, PlaybackStartTime, EnablePlayStateSaving);

                if (isCurrentMedia)
                {
                    break;
                }
            }

            HasUpdatedPlayState = true;
        }
Exemplo n.º 3
0
        internal void OnPlaybackFinished(BasePlaybackController controller, PlaybackStateEventArgs args)
        {
            if (args.Item == this)
            {
                // If there's still a valid position, fire progress one last time
                if (args.Position > 0)
                {
                    OnProgress(controller, args);
                }

                PlaybackStoppedByUser = args.StoppedByUser;

                MarkWatchedIfNeeded();
            }

            PlayState = PlayableItemPlayState.Stopped;

            // Fire finished event
            if (_PlaybackFinished != null)
            {
                Async.Queue("PlayableItem PlaybackFinished", () =>
                {
                    _PlaybackFinished(this, new GenericEventArgs<PlayableItem>() { Item = this });
                });
            }

            if (RaiseGlobalPlaybackEvents)
            {
                Application.CurrentInstance.RunPostPlayProcesses(this);
            }

            if (UnmountISOAfterPlayback)
            {
                Application.CurrentInstance.UnmountIso();
            }
        }
Exemplo n.º 4
0
        public void Play(PlayableItem playable)
        {
            CurrentlyPlayingItemId = playable.HasMediaItems ? playable.CurrentMedia.Id : CurrentItem.Id;
            MainPlayable = null; // just make sure this doesn't hang around

            Async.Queue(Async.ThreadPoolName.PlayAction, () =>
            {
                currentPlaybackController = playable.PlaybackController;

                playable.Play();

            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Play with intros - this is an overload in order not to break sig with existing mcml
        /// </summary>
        /// <param name="playable"></param>
        /// <param name="introPlayable"></param>
        public void Play(PlayableItem playable, PlayableItem introPlayable)
        {
            if (BackdropController.IsPlaying) PlaybackControllerHelper.Stop();

            if (introPlayable == null)
            {
                // Simulate optional param
                Play(playable);
            }
            else
            {
                CurrentlyPlayingItemId = playable.HasMediaItems ? playable.CurrentMedia.Id : CurrentItem.Id;

                Async.Queue(Async.ThreadPoolName.PlayIntros, () =>
                {
                    // save the main playable so we can play it when we're finished
                    MainPlayable = playable;
                    currentPlaybackController = introPlayable.PlaybackController;

                    // hook to finished event so we can kick off the main
                    introPlayable.PlaybackController.PlaybackFinished += IntroPlaybackFinished;

                    RecentUserInput = false;
                    SuppressInitialOverlay = true; // suppress the overlay for intros
                    introPlayable.Play();

                });
            }
        }
 private void UpdateCurrentMediaPlayState(BasePlaybackController controller, PlaybackStateEventArgs args)
 {
     if (CurrentMedia != null)
     {
         CurrentMedia.PlaybackStatus.PositionTicks = args.Position;
         Application.CurrentInstance.UpdatePlayState(CurrentMedia, CurrentMedia.PlaybackStatus, controller.IsPaused, EnablePlayStateSaving);
     }
 }
        internal void OnPlaybackFinished(BasePlaybackController controller, PlaybackStateEventArgs args)
        {
            if (args.Item == this && HasMediaItems)
            {
                // If there's still a valid position, fire progress one last time
                if (args.Position > 0)
                {
                    OnProgress(controller, args);
                }
                //update any previously played items to fully watched
                for (var i = 0; i < args.Item.CurrentMediaIndex; i++)
                    OnItemFinished(args.Item.MediaItems.ElementAt(i), long.MaxValue);

                //and then the current one with current state
                OnItemFinished(CurrentMedia, args.Position);
            }

            PlaybackStoppedByUser = args.StoppedByUser;


            PlayState = PlayableItemPlayState.Stopped;

            //DisplayUtil.RevertRefreshRate();

            // Fire finished event
            if (_PlaybackFinished != null)
            {
                Async.Queue(Async.ThreadPoolName.PlayableItemPlaybackFinished, () =>
                {
                    _PlaybackFinished(this, new GenericEventArgs<PlayableItem>() { Item = this });
                }); 
            }

            if (RaiseGlobalPlaybackEvents)
            {
                Application.CurrentInstance.RunPostPlayProcesses(this);
            }

            if (UnmountISOAfterPlayback)
            {
                Application.CurrentInstance.UnmountIso();
            }
        }
Exemplo n.º 8
0
        internal void PlaySecure(PlayableItem playable)
        {
            Async.Queue("Play Action", () =>
            {
                currentPlaybackController = playable.PlaybackController;

                playable.Play();

            });
        }
Exemplo n.º 9
0
        internal void PlaySecure(PlayableItem playable)
        {
            Async.Queue("Play Action", () =>
            {
                currentPlaybackController = playable.PlaybackController;

                playable.Play();

                if (!playable.QueueItem)
                {
                    //async this so it doesn't slow us down if the service isn't responding for some reason
                    Async.Queue("Cancel Svc Refresh", () =>
                    {
                        MBServiceController.SendCommandToService(IPCCommands.CancelRefresh); //tell service to stop
                    });
                }
            });
        }
Exemplo n.º 10
0
        /// <summary>
        /// Play with intros - this is an overload in order not to break sig with existing mcml
        /// </summary>
        /// <param name="playable"></param>
        /// <param name="introPlayable"></param>
        public void Play(PlayableItem playable, PlayableItem introPlayable)
        {
            if (BackdropController.IsPlaying) PlaybackControllerHelper.Stop();

            if (introPlayable == null)
            {
                // Simulate optional param
                Play(playable);
            }
            else
            {
                CurrentlyPlayingItemId = playable.HasMediaItems ? playable.CurrentMedia.Id : CurrentItem.Id;

                Async.Queue("Play Intros", () =>
                {
                    // save the main playable so we can play it when we're finished
                    MainPlayable = playable;
                    currentPlaybackController = introPlayable.PlaybackController;

                    // hook to finished event so we can kick off the main
                    introPlayable.PlaybackController.PlaybackFinished += IntroPlaybackFinished;

                    introPlayable.Play();

                });
            }
        }