コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
ファイル: Default.cs プロジェクト: zeroxist/MediaPortal-2
        public virtual IPlayerSlotController PrepareAudioPlayerSlotController(IPlayerManager playerManager, PlayerContextManager playerContextManager,
                                                                              bool concurrentVideo, out int currentPlayerSlotIndex)
        {
            int numActive;

            if (concurrentVideo)
            {
                numActive = playerContextManager.NumActivePlayerContexts;
                // Solve conflicts - close conflicting slots
                IPlayerContext secondaryPC = playerContextManager.GetPlayerContext(PlayerContextIndex.SECONDARY);
                if (secondaryPC != null)
                {
                    secondaryPC.Close();
                }
                IPlayerContext pcPrimary;
                if (numActive > 0 && (pcPrimary = playerContextManager.GetPlayerContext(PlayerContextIndex.PRIMARY)) != null && pcPrimary.AVType == AVType.Audio)
                {
                    pcPrimary.Close();
                }
            }
            else // !concurrentVideo
                 // Don't enable concurrent controllers: Close all except the primary slot controller
            {
                playerContextManager.CloseAllPlayerContexts();
            }
            numActive = playerContextManager.NumActivePlayerContexts;
            currentPlayerSlotIndex = numActive;
            return(playerManager.OpenSlot());
        }
コード例 #3
0
        protected static void CloseSecondaryPlayerContext()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pcSecondary          = playerContextManager.SecondaryPlayerContext;

            if (pcSecondary != null)
            {
                pcSecondary.Close();
            }
        }
コード例 #4
0
        public void ClosePlayerContext(int playerIndex)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc = playerContextManager.GetPlayerContext(playerIndex);

            if (pc != null)
            {
                pc.Close();
            }
        }
コード例 #5
0
        public async Task <bool> StartTimeshiftAsync(int slotIndex, IChannel channel)
        {
            if (TimeshiftControl == null || channel == null)
            {
                return(false);
            }

            ServiceRegistration.Get <ILogger>().Debug("SlimTvHandler: StartTimeshift slot {0} for channel '{1}'", slotIndex, channel.Name);

            int newSlotIndex = GetMatchingSlotIndex(slotIndex);

            if (_slotContexes[newSlotIndex].Channel != null && _slotContexes[newSlotIndex].Channel.MediaType != channel.MediaType)
            {
                // Switching between TV and radio - must close old player and start brand new one
                IPlayerContext playerContext = existingPlayerContext(newSlotIndex);
                if (playerContext == null)
                {
                    return(false);
                }
                playerContext.Close();
                await StopTimeshiftAsync(newSlotIndex);
            }
            var result = await TimeshiftControl.StartTimeshiftAsync(newSlotIndex, channel);

            IList <MultipleMediaItemAspect> pras;
            MediaItem timeshiftMediaItem = result.Result;

            if (result.Success && timeshiftMediaItem != null && MediaItemAspect.TryGetAspects(timeshiftMediaItem.Aspects, ProviderResourceAspect.Metadata, out pras))
            {
                string newAccessorPath = (string)pras[0].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH);

                // if slot was empty, start a new player
                if (_slotContexes[newSlotIndex].AccessorPath == null)
                {
                    AddOrUpdateTimeshiftContext(timeshiftMediaItem as LiveTvMediaItem, channel);
                    PlayerContextConcurrencyMode playMode = GetMatchingPlayMode();
                    await PlayItemsModel.PlayOrEnqueueItem(timeshiftMediaItem, true, playMode);
                }
                else
                {
                    try
                    {
                        _slotContexes[newSlotIndex].CardChanging = true;
                        UpdateExistingMediaItem(timeshiftMediaItem, newSlotIndex);
                    }
                    finally
                    {
                        _slotContexes[newSlotIndex].CardChanging = false;
                    }
                }
                _slotContexes[newSlotIndex].AccessorPath = newAccessorPath;
                _slotContexes[newSlotIndex].Channel      = channel;
            }
            return(result.Success);
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        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();
            }
        }
コード例 #9
0
        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();
            }
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
ファイル: Default.cs プロジェクト: zeroxist/MediaPortal-2
        public virtual IPlayerSlotController PrepareVideoPlayerSlotController(IPlayerManager playerManager, PlayerContextManager playerContextManager,
                                                                              PlayerContextConcurrencyMode concurrencyMode, out bool makePrimaryPlayer, out int audioPlayerSlotIndex, out int currentPlayerSlotIndex)
        {
            IList <IPlayerContext> playerContexts = playerContextManager.PlayerContexts;
            int numActive = playerContexts.Count;
            IPlayerSlotController result;

            switch (concurrencyMode)
            {
            case PlayerContextConcurrencyMode.ConcurrentAudio:
                if (numActive > 1 && playerContexts[PlayerContextIndex.SECONDARY].AVType == AVType.Audio)
                { // The secondary slot is an audio player slot
                    IPlayerContext playerContext = playerContexts[PlayerContextIndex.PRIMARY];
                    result               = playerContext.Revoke();
                    makePrimaryPlayer    = true;
                    audioPlayerSlotIndex = PlayerContextIndex.SECONDARY;
                }
                else if (numActive == 1 && playerContexts[PlayerContextIndex.PRIMARY].AVType == AVType.Audio)
                { // The primary slot is an audio player slot
                    result               = playerManager.OpenSlot();
                    makePrimaryPlayer    = true;
                    audioPlayerSlotIndex = PlayerContextIndex.SECONDARY;
                }
                else
                { // No audio slot available
                    playerContextManager.CloseAllPlayerContexts();
                    result               = playerManager.OpenSlot();
                    makePrimaryPlayer    = true;
                    audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
                }
                break;

            case PlayerContextConcurrencyMode.ConcurrentVideo:
                if (numActive >= 1 && playerContexts[PlayerContextIndex.PRIMARY].AVType == AVType.Video)
                { // The primary slot is a video player slot
                    if (numActive > 1)
                    {
                        IPlayerContext pcSecondary = playerContextManager.GetPlayerContext(PlayerContextIndex.SECONDARY);
                        pcSecondary.Close();
                    }
                    result               = playerManager.OpenSlot();
                    makePrimaryPlayer    = false;
                    audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
                }
                else
                {
                    playerContextManager.CloseAllPlayerContexts();
                    result               = playerManager.OpenSlot();
                    makePrimaryPlayer    = true;
                    audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
                }
                break;

            default:
                // Don't enable concurrent controllers: Close all except the primary slot controller
                playerContextManager.CloseAllPlayerContexts();
                result               = playerManager.OpenSlot();
                makePrimaryPlayer    = true;
                audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
                break;
            }
            currentPlayerSlotIndex = makePrimaryPlayer ? PlayerContextIndex.PRIMARY : PlayerContextIndex.SECONDARY;
            return(result);
        }