Instance Property

playerVoiceChatStateDidChangeHandler

A block that is called when a participant changes state.

Declaration

var playerVoiceChatStateDidChangeHandler: (GKPlayer, GKVoiceChat.PlayerState) -> Void { get set }

Discussion

Your game sets this property with a block to be called when the state of any participant in the chat changes (including the local player). The block receives the following parameters:

player

The GKPlayer object that identifies the player whose status changed.

state

The new state of the player. See GKVoiceChat.PlayerState.

Listing 1 shows an implementation of an update handler for the player state.

Listing 1

Receiving updates about the player

teamChat.playerVoiceChatStateDidChangeHandler = ^(GKPlayer *player, GKVoiceChatPlayerState state) {
     switch (state)
     {
         case GKVoiceChatPlayerSpeaking:
            // Insert code to highlight the player's picture.
             break;
         case GKVoiceChatPlayerSilent:
            // Insert code to dim the player's picture.
             break;
      }
   };

See Also

Receiving Updates About Other Participants

enum GKVoiceChat.PlayerState

The states returned to your game about other players in a voice chat.