protected void HandlePlayerEnded(IPlayerSlotController psc, uint activationSequence)
        {
            IPlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || !pc.IsValid || psc.ActivationSequence != activationSequence)
            {
                return;
            }
            if (!pc.NextItem())
            {
                if (pc.CloseWhenFinished)
                {
                    pc.Close();
                }
                else
                {
                    psc.Stop();
                }
                if (psc.SlotIndex == PlayerManagerConsts.PRIMARY_SLOT)
                {
                    StepOutOfPlayerWFState(PlayerWFStateType.FullscreenContent);
                }
                if (psc.SlotIndex == CurrentPlayerIndex)
                {
                    StepOutOfPlayerWFState(PlayerWFStateType.CurrentlyPlaying);
                }
            }
        }
        protected void HandleRequestNextItem(IPlayerSlotController psc)
        {
            PlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || !pc.IsActive)
            {
                return;
            }
            pc.RequestNextItem_NoLock();
        }
        protected void HandleRequestNextItem(IPlayerSlotController psc, uint activationSequence)
        {
            PlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || !pc.IsValid || psc.ActivationSequence != activationSequence)
            {
                return;
            }
            pc.RequestNextItem_NoLock();
        }
        protected void HandleRequestNextItem(IPlayerSlotController psc)
        {
            PlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || !pc.IsActive)
            {
                return;
            }
            HandleProgress(TimeSpan.FromSeconds(-1), pc.CurrentMediaItem, true).Wait();
            pc.RequestNextItem_NoLock();
        }
        protected void HandlePlayerStopped(IPlayerSlotController psc)
        {
            IPlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || !pc.IsActive)
            {
                return;
            }
            // We get the player message asynchronously, so we have to check the state of the slot again to ensure
            // we close the correct one
            if (pc.CloseWhenFinished && pc.CurrentPlayer == null)
            {
                pc.Close();
            }
            CheckMediaWorkflowStates_Async();
        }
        protected void HandlePlayerStopped(IPlayerSlotController psc, TimeSpan?stopPosition)
        {
            IPlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || !pc.IsActive)
            {
                return;
            }
            if (stopPosition.HasValue)
            {
                HandleProgress(stopPosition.Value, pc.CurrentMediaItem, false).Wait();
            }
            // We get the player message asynchronously, so we have to check the state of the slot again to ensure
            // we close the correct one
            if (pc.CloseWhenFinished && pc.CurrentPlayer == null)
            {
                pc.Close();
            }
            CheckMediaWorkflowStates_Async();
        }
        protected void HandlePlayerEnded(IPlayerSlotController psc)
        {
            IPlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || !pc.IsActive)
            {
                return;
            }
            if (!pc.NextItem())
            {
                if (pc.CloseWhenFinished)
                {
                    pc.Close();
                }
                else
                {
                    psc.Stop();
                }
                CheckMediaWorkflowStates_Async();
            }
        }
        protected void HandlePlayerEnded(IPlayerSlotController psc)
        {
            IPlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || !pc.IsActive)
            {
                return;
            }
            HandleProgress(TimeSpan.FromSeconds(-1), pc.CurrentMediaItem, true).Wait();
            if (!pc.NextItem())
            {
                if (pc.CloseWhenFinished)
                {
                    pc.Close();
                }
                else
                {
                    psc.Stop();
                }
                CheckMediaWorkflowStates_Async();
            }
        }
        protected void HandlePlayerStopped(IPlayerSlotController psc, uint activationSequence)
        {
            IPlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || !pc.IsValid || psc.ActivationSequence != activationSequence)
            {
                return;
            }
            // We get the player message asynchronously, so we have to check the state of the slot again to ensure
            // we close the correct one
            if (pc.CloseWhenFinished && pc.CurrentPlayer == null)
            {
                pc.Close();
            }
            if (psc.SlotIndex == PlayerManagerConsts.PRIMARY_SLOT)
            {
                StepOutOfPlayerWFState(PlayerWFStateType.FullscreenContent);
            }
            if (psc.SlotIndex == CurrentPlayerIndex)
            {
                StepOutOfPlayerWFState(PlayerWFStateType.CurrentlyPlaying);
            }
        }
        protected static PlayerContext GetPlayerContextInternal(int slotIndex)
        {
            IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>();

            return(PlayerContext.GetPlayerContext(playerManager.GetPlayerSlotController(slotIndex)));
        }