Ejemplo n.º 1
0
        public virtual void PrepareAudioPlayer(IPlayerManager playerManager, IList <IPlayerContext> playerContexts, bool concurrentVideo, Guid mediaModuleId,
                                               out IPlayerSlotController slotController, ref int audioSlotIndex, ref int currentPlayerIndex)
        {
            if (concurrentVideo)
            {
                int numActive = playerManager.NumActiveSlots;
                // Solve conflicts - close conflicting slots
                if (numActive > 1)
                {
                    playerManager.CloseSlot(PlayerManagerConsts.SECONDARY_SLOT);
                }
                IPlayerContext pc;
                if (numActive > 0 && (pc = playerContexts[PlayerManagerConsts.PRIMARY_SLOT]) != null && pc.AVType == AVType.Audio)
                {
                    playerManager.CloseSlot(PlayerManagerConsts.PRIMARY_SLOT);
                }
            }
            else // !concurrentVideo
                 // Don't enable concurrent controllers: Close all except the primary slot controller
            {
                playerManager.CloseAllSlots();
            }
            // Open new slot
            int slotIndex;

            playerManager.OpenSlot(out slotIndex, out slotController);
            audioSlotIndex     = slotController.SlotIndex;
            currentPlayerIndex = slotIndex;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Discards any current player and plays the media items of type <paramref name="avType"/> returned by the given
        /// <paramref name="getMediaItemsFunction"/>.
        /// </summary>
        /// <param name="getMediaItemsFunction">Function returning the media items to be played.</param>
        /// <param name="avType">AV type of media items returned.</param>
        public static void PlayItems(GetMediaItemsDlgt getMediaItemsFunction, AVType avType)
        {
            IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>();

            playerManager.CloseSlot(PlayerManagerConsts.SECONDARY_SLOT);
            PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.None);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Discards any current player and plays the specified media <paramref name="item"/>.
        /// </summary>
        /// <param name="item">Media item to be played.</param>
        public static void PlayItem(MediaItem item)
        {
            IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>();

            playerManager.CloseSlot(PlayerManagerConsts.SECONDARY_SLOT);
            PlayOrEnqueueItem(item, true, PlayerContextConcurrencyMode.None);
        }
Ejemplo n.º 4
0
        public virtual void PrepareVideoPlayer(IPlayerManager playerManager, IList <IPlayerContext> playerContexts, PlayerContextConcurrencyMode concurrencyMode, Guid mediaModuleId,
                                               out IPlayerSlotController slotController, ref int audioSlotIndex, ref int currentPlayerIndex)
        {
            int numActive = playerContexts.Count;
            int slotIndex;

            switch (concurrencyMode)
            {
            case PlayerContextConcurrencyMode.ConcurrentAudio:
                if (numActive > 1 && playerContexts[1].AVType == AVType.Audio)
                { // The secondary slot is an audio player slot
                    slotIndex = PlayerManagerConsts.PRIMARY_SLOT;
                    IPlayerContext pc = playerContexts[0];
                    pc.Reset(); // Necessary to reset the player context to disable the auto close function (pc.CloseWhenFinished)
                    playerManager.ResetSlot(slotIndex, out slotController);
                    audioSlotIndex = PlayerManagerConsts.SECONDARY_SLOT;
                }
                else if (numActive == 1 && playerContexts[0].AVType == AVType.Audio)
                { // The primary slot is an audio player slot
                    playerManager.OpenSlot(out slotIndex, out slotController);
                    // Make new video slot the primary slot
                    playerManager.SwitchSlots();
                    audioSlotIndex = PlayerManagerConsts.SECONDARY_SLOT;
                }
                else
                { // No audio slot available
                    playerManager.CloseAllSlots();
                    playerManager.OpenSlot(out slotIndex, out slotController);
                    audioSlotIndex = PlayerManagerConsts.PRIMARY_SLOT;
                }
                break;

            case PlayerContextConcurrencyMode.ConcurrentVideo:
                if (numActive >= 1 && playerContexts[0].AVType == AVType.Video)
                { // The primary slot is a video player slot
                    if (numActive > 1)
                    {
                        playerManager.CloseSlot(PlayerManagerConsts.SECONDARY_SLOT);
                    }
                    playerManager.OpenSlot(out slotIndex, out slotController);
                    audioSlotIndex = PlayerManagerConsts.PRIMARY_SLOT;
                }
                else
                {
                    playerManager.CloseAllSlots();
                    playerManager.OpenSlot(out slotIndex, out slotController);
                    audioSlotIndex = PlayerManagerConsts.PRIMARY_SLOT;
                }
                break;

            default:
                // Don't enable concurrent controllers: Close all except the primary slot controller
                playerManager.CloseAllSlots();
                playerManager.OpenSlot(out slotIndex, out slotController);
                audioSlotIndex = PlayerManagerConsts.PRIMARY_SLOT;
                break;
            }
            currentPlayerIndex = slotIndex;
        }
Ejemplo n.º 5
0
 public void EndBackgroundPlayback()
 {
     if (_backgroundPsc != null)
     {
         IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>();
         playerManager.CloseSlot(_backgroundPsc);
         _backgroundPsc = null;
         VideoPlayer    = null;
     }
 }
Ejemplo n.º 6
0
 public virtual void PrepareAudioPlayer(IPlayerManager playerManager, IList<IPlayerContext> playerContexts, bool concurrentVideo, Guid mediaModuleId,
     out IPlayerSlotController slotController, ref int audioSlotIndex, ref int currentPlayerIndex)
 {
   if (concurrentVideo)
   {
     int numActive = playerManager.NumActiveSlots;
     // Solve conflicts - close conflicting slots
     if (numActive > 1)
       playerManager.CloseSlot(PlayerManagerConsts.SECONDARY_SLOT);
     IPlayerContext pc;
     if (numActive > 0 && (pc = playerContexts[PlayerManagerConsts.PRIMARY_SLOT]) != null && pc.AVType == AVType.Audio)
       playerManager.CloseSlot(PlayerManagerConsts.PRIMARY_SLOT);
   }
   else // !concurrentVideo
     // Don't enable concurrent controllers: Close all except the primary slot controller
     playerManager.CloseAllSlots();
   // Open new slot
   int slotIndex;
   playerManager.OpenSlot(out slotIndex, out slotController);
   audioSlotIndex = slotController.SlotIndex;
   currentPlayerIndex = slotIndex;
 }
        public void Shutdown()
        {
            IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>();

            ForEach((pc, slotIndex) =>
            {
                IPlayerSlotController psc = pc.Revoke();
                if (psc != null)
                {
                    playerManager.CloseSlot(psc);
                }
            });
            UnsubscribeFromMessages();
        }
Ejemplo n.º 8
0
        public void Close()
        {
            IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>();

            playerManager.CloseSlot(_slotController);
        }
Ejemplo n.º 9
0
 public virtual void PrepareVideoPlayer(IPlayerManager playerManager, IList<IPlayerContext> playerContexts, PlayerContextConcurrencyMode concurrencyMode, Guid mediaModuleId,
     out IPlayerSlotController slotController, ref int audioSlotIndex, ref int currentPlayerIndex)
 {
     int numActive = playerContexts.Count;
     int slotIndex;
     switch (concurrencyMode)
     {
       case PlayerContextConcurrencyMode.ConcurrentAudio:
         if (numActive > 1 && playerContexts[1].AVType == AVType.Audio)
         { // The secondary slot is an audio player slot
           slotIndex = PlayerManagerConsts.PRIMARY_SLOT;
           IPlayerContext pc = playerContexts[0];
           pc.Reset(); // Necessary to reset the player context to disable the auto close function (pc.CloseWhenFinished)
           playerManager.ResetSlot(slotIndex, out slotController);
           audioSlotIndex = PlayerManagerConsts.SECONDARY_SLOT;
         }
         else if (numActive == 1 && playerContexts[0].AVType == AVType.Audio)
         { // The primary slot is an audio player slot
           playerManager.OpenSlot(out slotIndex, out slotController);
           // Make new video slot the primary slot
           playerManager.SwitchSlots();
           audioSlotIndex = PlayerManagerConsts.SECONDARY_SLOT;
         }
         else
         { // No audio slot available
           playerManager.CloseAllSlots();
           playerManager.OpenSlot(out slotIndex, out slotController);
           audioSlotIndex = PlayerManagerConsts.PRIMARY_SLOT;
         }
         break;
       case PlayerContextConcurrencyMode.ConcurrentVideo:
         if (numActive >= 1 && playerContexts[0].AVType == AVType.Video)
         { // The primary slot is a video player slot
           if (numActive > 1)
             playerManager.CloseSlot(PlayerManagerConsts.SECONDARY_SLOT);
           playerManager.OpenSlot(out slotIndex, out slotController);
           audioSlotIndex = PlayerManagerConsts.PRIMARY_SLOT;
         }
         else
         {
           playerManager.CloseAllSlots();
           playerManager.OpenSlot(out slotIndex, out slotController);
           audioSlotIndex = PlayerManagerConsts.PRIMARY_SLOT;
         }
         break;
       default:
         // Don't enable concurrent controllers: Close all except the primary slot controller
         playerManager.CloseAllSlots();
         playerManager.OpenSlot(out slotIndex, out slotController);
         audioSlotIndex = PlayerManagerConsts.PRIMARY_SLOT;
         break;
     }
   currentPlayerIndex = slotIndex;
 }
Ejemplo n.º 10
0
        public void ClosePlayerContext(int playerIndex)
        {
            IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>();

            playerManager.CloseSlot(playerIndex);
        }