public void SwitchPipPlayers()
 {
     lock (SyncObj)
     {
         IList <PlayerContext> pcs = GetPlayerContexts();
         if (pcs.Count < 2)
         {
             // We don't have enough active slots to switch
             return;
         }
         PlayerContext first  = pcs[0];
         PlayerContext second = pcs[1];
         first.IsPrimaryPlayerContext  = !first.IsPrimaryPlayerContext;
         second.IsPrimaryPlayerContext = !second.IsPrimaryPlayerContext;
         ClearPlayerContextsCache();
         // Audio and Current player change their index automatically as the information is stored in the player context instance itself
         PlayerContextManagerMessaging.SendPlayerContextManagerMessage(PlayerContextManagerMessaging.MessageType.PlayerSlotsChanged);
     }
 }
        protected void SetCurrentPlayerContext(Func <PlayerContext, int, bool> selector)
        {
            bool           changed = false;
            IPlayerContext newCurrentPlayerContext = null;

            ForEach((pc, slotIndex) =>
            {
                bool newVal = selector(pc, slotIndex);
                if (pc.IsCurrentPlayerContext != newVal)
                {
                    changed = true;
                    pc.IsCurrentPlayerContext = newVal;
                }
            });
            if (!changed)
            {
                return;
            }
            CleanupPlayerContexts();
            CheckMediaWorkflowStates_Async();
            PlayerContextManagerMessaging.SendPlayerContextManagerMessage(PlayerContextManagerMessaging.MessageType.CurrentPlayerChanged, newCurrentPlayerContext);
        }