Configure the audio-only mode

Updated at:

ApsaraVideo Real-time Communication (ARTC) SDK for Web supports the audio-only mode. If your business scenario requires audio-only calling, such as a voice chat room, you can enable the audio-only mode before you join the channel.

Usage notes

If you try to enable the audio-only mode after you join a channel, an error occurs. After you enable the audio-only mode, you cannot call video related methods, such as the enableLocalVideo method that is used to turn on or off the camera.

Implementation

// Make sure that an AliRtcEngine instance is created.
// Enable the audio-only mode.
aliRtcEngine.setAudioOnlyMode(true);

If you want to query whether the audio-only mode is already enabled, call the isAudioOnly method.

// Make sure that an AliRtcEngine instance is created.
if (ins.isAudioOnly()) {
  console.log('The current mode is audio only.');
} else {
  console.log('The current mode is not audio only.');
}