tencent cloud

Feedback

Voice Chat Role Configuration

Last updated: 2023-05-19 15:13:57
    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.

    Use Cases

    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.

    Prerequisites

    You have created a GME application and obtained the AppID and Key of the SDK as instructed in Activating Services.
    You have activated the voice chat service of GME as instructed in Activating Services.
    You have integrated the GME SDK as instructed in Quick Integration of Native SDK.

    Integration directions

    Below is the process of connecting to the commanding voice mode:
    1. Use GME
    2. Set the role
    6. Exit the room

    Step 1. Use GME

    For more information on how to call and integrate the GME SDK, see Quick Integration of Native SDK, Quick Integration of SDK for Unity, and Quick Integration of SDK for Unreal Engine.

    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.

    Function prototype

    public abstract int SetAudioRole(ITMG_AUDIO_MEMBER_ROLE role);
    Parameter
    Type
    Description
    role
    ITMG_AUDIO_MEMBER_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.

    Sample code

    ITMGContext.GetInstance().SetAudioRole(ITMG_AUDIO_MEMBER_ROLE.ITMG_AUDIO_MEMBER_ROLE_AUDIENCE);

    Step 3. Use the real-time voice service

    Call the EnterRoom API to enter a voice chat room.

    Step 4. Enable the mic

    If your role is host, you can normally call the EnableMic and 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 EnableMic API.

    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

    After the ExitRoom API is called to exit the voice chat room, the role status becomes invalid, and the role needs to be set again.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support