public IPlayerContext OpenVideoPlayerContext(Guid mediaModuleId, string name, PlayerContextConcurrencyMode concurrencyMode,
                                                     Guid currentlyPlayingWorkflowStateId, Guid fullscreenContentWorkflowStateId)
        {
            IOpenPlayerStrategy strategy      = GetOpenPlayerStrategy();
            IPlayerManager      playerManager = ServiceRegistration.Get <IPlayerManager>();

            lock (playerManager.SyncObj)
            {
                IList <IPlayerContext> playerContexts = GetPlayerContexts();
                IPlayerSlotController  slotController;
                int audioSlotIndex     = playerManager.AudioSlotIndex;
                int currentPlayerIndex = CurrentPlayerIndex;
                strategy.PrepareVideoPlayer(playerManager, playerContexts, concurrencyMode, mediaModuleId, out slotController, ref audioSlotIndex, ref currentPlayerIndex);
                PlayerContextManagerMessaging.SendUpdatePlayerRolesMessage(currentPlayerIndex, audioSlotIndex);
                return(new PlayerContext(this, slotController, mediaModuleId, name, AVType.Video,
                                         currentlyPlayingWorkflowStateId, fullscreenContentWorkflowStateId));
            }
        }
        public IPlayerContext OpenAudioPlayerContext(Guid mediaModuleId, string name, bool concurrentVideo, Guid currentlyPlayingWorkflowStateId,
                                                     Guid fullscreenContentWorkflowStateId)
        {
            IOpenPlayerStrategy strategy      = GetOpenPlayerStrategy();
            IPlayerManager      playerManager = ServiceRegistration.Get <IPlayerManager>();

            lock (playerManager.SyncObj)
            {
                IList <IPlayerContext> playerContexts = GetPlayerContexts();
                IPlayerSlotController  slotController;
                int audioSlotIndex     = playerManager.AudioSlotIndex;
                int currentPlayerIndex = CurrentPlayerIndex;
                strategy.PrepareAudioPlayer(playerManager, playerContexts, concurrentVideo, mediaModuleId, out slotController, ref audioSlotIndex, ref currentPlayerIndex);
                playerManager.AudioSlotIndex = audioSlotIndex;
                CurrentPlayerIndex           = currentPlayerIndex;
                return(new PlayerContext(this, slotController, mediaModuleId, name, AVType.Audio,
                                         currentlyPlayingWorkflowStateId, fullscreenContentWorkflowStateId));
            }
        }
        public IPlayerContext OpenVideoPlayerContext(Guid mediaModuleId, string name, PlayerContextConcurrencyMode concurrencyMode,
                                                     Guid currentlyPlayingWorkflowStateId, Guid fullscreenContentWorkflowStateId)
        {
            IOpenPlayerStrategy strategy      = GetOpenPlayerStrategy();
            IPlayerManager      playerManager = ServiceRegistration.Get <IPlayerManager>();

            lock (playerManager.SyncObj)
            {
                int  audioPlayerSlotIndex;
                int  currentPlayerSlotIndex;
                bool makePrimaryPlayer;
                IPlayerSlotController slotController = strategy.PrepareVideoPlayerSlotController(playerManager, this, concurrencyMode,
                                                                                                 out makePrimaryPlayer, out audioPlayerSlotIndex, out currentPlayerSlotIndex);
                slotController.Closed += OnPlayerSlotControllerClosed;
                if (makePrimaryPlayer)
                {
                    PlayerContext oldPrimaryPC = GetPlayerContextInternal(PlayerContextIndex.PRIMARY);
                    if (oldPrimaryPC != null)
                    {
                        oldPrimaryPC.IsPrimaryPlayerContext = false;
                    }
                }
                PlayerContext result = new PlayerContext(slotController, mediaModuleId, name, AVType.Video, currentlyPlayingWorkflowStateId, fullscreenContentWorkflowStateId);
                if (makePrimaryPlayer)
                {
                    result.IsPrimaryPlayerContext = true;
                }
                CleanupPlayerContexts();
                IList <IPlayerContext> playerContexts = PlayerContexts;
                int lastPlayerContextIndex            = playerContexts.Count - 1;
                if (currentPlayerSlotIndex > lastPlayerContextIndex)
                {
                    currentPlayerSlotIndex = lastPlayerContextIndex;
                }
                if (audioPlayerSlotIndex > lastPlayerContextIndex)
                {
                    audioPlayerSlotIndex = lastPlayerContextIndex;
                }
                PlayerContextManagerMessaging.SendUpdatePlayerRolesMessage(playerContexts[currentPlayerSlotIndex], playerContexts[audioPlayerSlotIndex]);
                return(result);
            }
        }
        public IPlayerContext OpenAudioPlayerContext(Guid mediaModuleId, string name, bool concurrentVideo, Guid currentlyPlayingWorkflowStateId,
                                                     Guid fullscreenContentWorkflowStateId)
        {
            IOpenPlayerStrategy strategy      = GetOpenPlayerStrategy();
            IPlayerManager      playerManager = ServiceRegistration.Get <IPlayerManager>();

            lock (playerManager.SyncObj)
            {
                int currentPlayerSlotIndex;
                IPlayerSlotController slotController = strategy.PrepareAudioPlayerSlotController(playerManager, this, concurrentVideo, out currentPlayerSlotIndex);
                slotController.Closed += OnPlayerSlotControllerClosed;
                IPlayerContext result = new PlayerContext(slotController, mediaModuleId, name, AVType.Audio, currentlyPlayingWorkflowStateId, fullscreenContentWorkflowStateId);
                CleanupPlayerContexts();
                IList <IPlayerContext> playerContexts = PlayerContexts;
                int lastPlayerContextIndex            = playerContexts.Count - 1;
                if (currentPlayerSlotIndex > lastPlayerContextIndex)
                {
                    currentPlayerSlotIndex = lastPlayerContextIndex;
                }
                PlayerContextManagerMessaging.SendUpdatePlayerRolesMessage(playerContexts[currentPlayerSlotIndex], playerContexts[lastPlayerContextIndex]);
                return(result);
            }
        }