Note: Currently, GME 3.x does not support voice chat role configuration.
This document describes how to access and debug GME APIs for the commanding voice mode.
In commanding game scenarios, GME provides the host and listener roles. If a user sets the role to host before room entry, the user can enable the mic to speak and enable the speaker to hear others talking in the room after room entry. If the user enters the room as a listener, the user cannot speak in the room after room entry even the mic is enabled.
You have created a GME application and obtained the
Key of the SDK as instructed in Activating Services.
Below is the process of connecting to the commanding voice mode:
Step 1. Use GME
Step 2. Setting the role
Before calling the
EnterRoom API, you need to call the
SetAudioRole API to set the role of the current user in voice chat.
public abstract int SetAudioRole(ITMG_AUDIO_MEMBER_ROLE role);
ITMG_AUDIO_MEMBER_ROLE_ANCHOR: Host, who can enable the mic and speaker in the room.
ITMG_AUDIO_MEMBER_ROLE_AUDIENCE: Listener, who can enable only the speaker in the room to listen to others.
Step 3. Use the real-time voice service
EnterRoom API to enter a voice chat room.
Step 4. Enable the mic
If your role is host, you can normally call the
EnableSpeaker APIs to enable the mic and speaker respectively.
If your role is listener, you can normally use the
EnableSpeaker API to enable the speaker, but the
AV_ERR_INVALID_ARGUMENT error code (1004) will be returned to remind that you are in listener mode and the mic cannot be enabled when you call the
Step 5. Change the role
In the room, you can call
SetAudioRole to change the role.
If the role is not set, the new role will be used.
If the role is set, the new role will be used.
If no role is set or the role is host and you are speaking with the mic enabled, but the mic is still enabled after the role is changed to listener, we recommend that you call the
EnableMic API at the business layer to change the mic status and the mic UI status.
Step 6. Exit the room
ExitRoom API is called to exit the voice chat room, the role status becomes invalid, and the role needs to be set again.