Updated on 2023-11-01 GMT+08:00

Switching the Audio Mode

Function

Before joining a meeting, a user can call enableTopThreeAudioMode to receive the three loudest audio streams in the room.

During the meeting, switchAudioMode(2) can be called to switch the audio mode to the subscription mode. In this mode, the local user can receive the remote audio streams only after subscribing to them.

During the meeting, switchAudioMode(3) can be called to receive the three loudest audio streams in the room. In this mode, the local user can receive the three loudest audio streams in the room without subscribing to the remote audio streams.

API Calling

Implementation

  1. Determine whether to receive the three loudest audio streams in the room.

    Before joining a meeting, call enableTopThreeAudioMode to determine whether to receive the three loudest audio streams in the room. true indicates that the function is enabled and false indicates that the function is disabled.

    The sample code is as follows:

    this.client.enableTopThreeAudioMode(true)
  2. Join a room.

    Refer to the sequence diagram for joining a room in API Calling.

  3. Set the maximum audio volume of the three loudest users.

    Call setVolume4TopThree to set the maximum audio volume of the three loudest users. The value ranges from 0 to 100.

    The sample code is as follows:

    // volume indicates the volume.
    let volume = 50
    this.client.setVolume4TopThree(volume)
  4. Enable or disable audio tracks of the three loudest users.

    Call muteAudio4TopThree to enable or disable audio tracks of the three loudest users. true indicates that their audio tracks are disabled and false indicates that their audio tracks are enabled.

    The sample code is as follows:

    this.client.muteAudio4TopThree(true)
  5. Switch the audio mode.

    Call switchAudioMode to switch the audio mode.

    switchAudioMode(2) indicates the audio subscription mode and switchAudioMode(3) indicates that the three loudest audio streams are subscribed to.

    The sample code is as follows:

    this.client.switchAudioMode(2)
    this.client.switchAudioMode(3)