protected void UpdatePlayerConfigurationMenu() { // Some updates could be avoided if we tracked a "dirty" flag and break execution if !dirty lock (_syncObj) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>(); int numActivePlayers = playerContextManager.NumActivePlayerContexts; int slotNo = 0; IList <IPlayerContext> playerContexts = playerContextManager.PlayerContexts; IList <string> playerNames = new List <string>(playerContexts.Select(pc => GetNameForPlayerContext(pc, slotNo++))); _playerConfigurationMenu.Clear(); // Change player focus if (numActivePlayers > 1) { // Set player focus int newCurrentPlayer = 1 - playerContextManager.CurrentPlayerIndex; string name = playerNames[newCurrentPlayer]; if (name != null) { ListItem item = new ListItem(Consts.KEY_NAME, LocalizationHelper.CreateResourceString(Consts.RES_FOCUS_PLAYER).Evaluate(name)) { Command = new MethodDelegateCommand(() => SetCurrentPlayer(newCurrentPlayer)) }; item.AdditionalProperties[Consts.KEY_NAVIGATION_MODE] = NavigationMode.ExitPCWorkflow; _playerConfigurationMenu.Add(item); } } // Switch players if (numActivePlayers > 1 && playerContextManager.IsPipActive) { ListItem item = new ListItem(Consts.KEY_NAME, Consts.RES_SWITCH_PIP_PLAYERS) { Command = new MethodDelegateCommand(SwitchPrimarySecondaryPlayer) }; item.AdditionalProperties[Consts.KEY_NAVIGATION_MODE] = NavigationMode.ExitPCWorkflow; _playerConfigurationMenu.Add(item); } // Change geometry IList <IPlayerContext> videoPCs = GetVideoPlayerContexts(); for (int i = 0; i < videoPCs.Count; i++) { IPlayerContext pc = videoPCs[i]; string geometry = LocalizationHelper.CreateResourceString(Consts.RES_CHOOSE_PLAYER_GEOMETRY).Evaluate(); string entryName = videoPCs.Count > 1 ? string.Format("{0} ({1})", geometry, GetNameForPlayerContext(pc, i)) : geometry; ListItem item = new ListItem(Consts.KEY_NAME, entryName) { Command = new MethodDelegateCommand(() => OpenChooseGeometryDialog(pc)) }; item.AdditionalProperties[Consts.KEY_NAVIGATION_MODE] = NavigationMode.SuccessorDialog; _playerConfigurationMenu.Add(item); } // Change rendering effect for (int i = 0; i < videoPCs.Count; i++) { IPlayerContext pc = videoPCs[i]; string effect = LocalizationHelper.CreateResourceString(Consts.RES_CHOOSE_PLAYER_EFFECT).Evaluate(); string entryName = videoPCs.Count > 1 ? string.Format("{0} ({1})", effect, GetNameForPlayerContext(pc, i)) : effect; ListItem item = new ListItem(Consts.KEY_NAME, entryName) { Command = new MethodDelegateCommand(() => OpenChooseEffectDialog(pc)) }; item.AdditionalProperties[Consts.KEY_NAVIGATION_MODE] = NavigationMode.SuccessorDialog; _playerConfigurationMenu.Add(item); } // Audio streams AudioStreamDescriptor currentAudioStream; ICollection <AudioStreamDescriptor> audioStreams = playerContextManager.GetAvailableAudioStreams(out currentAudioStream); if (audioStreams.Count > 1) { ListItem item = new ListItem(Consts.KEY_NAME, Consts.RES_CHOOSE_AUDIO_STREAM) { Command = new MethodDelegateCommand(OpenChooseAudioStreamDialog) }; item.AdditionalProperties[Consts.KEY_NAVIGATION_MODE] = NavigationMode.SuccessorDialog; _playerConfigurationMenu.Add(item); } // Mute if (numActivePlayers > 0) { ListItem item; if (playerManager.Muted) { item = new ListItem(Consts.KEY_NAME, Consts.RES_MUTE_OFF) { Command = new MethodDelegateCommand(PlayersResetMute) } } ; else { item = new ListItem(Consts.KEY_NAME, Consts.RES_MUTE) { Command = new MethodDelegateCommand(PlayersMute) } }; item.AdditionalProperties[Consts.KEY_NAVIGATION_MODE] = NavigationMode.ExitPCWorkflow; _playerConfigurationMenu.Add(item); } // Close player for (int i = 0; i < numActivePlayers; i++) { string name = numActivePlayers > 1 ? playerNames[i] : string.Empty; IPlayerContext pc = playerContexts[i]; if (name != null) { ListItem item = new ListItem(Consts.KEY_NAME, LocalizationHelper.CreateResourceString(Consts.RES_CLOSE_PLAYER_CONTEXT).Evaluate(name)) { Command = new MethodDelegateCommand(pc.Close) }; _playerConfigurationMenu.Add(item); } } _playerConfigurationMenu.FireChange(); } }