
# 切换音频模式
#### 功能描述
用户在入会前可通过调用enableTopThreeAudioMode切换为音频最大三方模式。
会中通过调用switchAudioMode(2)将音频切换为订阅模式。订阅模式下，本地用户必须通过主动订阅远端用户音频流，才可接收该用户音频。
会中通过调用switchAudioMode(3)将音频切换为最大三方模式。最大三方模式下，本地用户不需要单独主动订阅某个远端用户音频流，即可接收当前房间内声音最大的三个用户的音频。
 #### 接口调用流程
![](https://support.huaweicloud.com/bestpractice-rtc/zh-cn_image_0000001182083944.png)
#### 实现过程
1. **加入房间前设置音频最大三方模式**
   入会前调用enableTopThreeAudioMode设置是否开启音频最大三方模式。true表示开启音频最大三方，false表示不开启。
   示例代码如下：
   ```
   this.client.enableTopThreeAudioMode(true)
   ```
   
2. **加入房间**
   参考[接口调用流程]中加入房间的时序图步骤。
   
3. **设置音频最大三方音量值**
   调用setVolume4TopThree接口可以设置音频最大三方模式的音量值，取值范围为\[0,100\]。
   示例代码如下：
   ```
   // volume：音量值
   let volume = 50
   this.client.setVolume4TopThree(volume)
   ```
   
4. **开启/禁用音频最大三方模式的音轨**
   调用muteAudio4TopThree接口可以开启/禁用音频最大三方模式的音轨，true表示禁用音频最大三方模式的音轨，false表示开启音频最大三方模式的音轨。
   示例代码如下：
   ```
   this.client.muteAudio4TopThree(true)
   ```
   
5. **切换音频订阅模式/音频最大三方模式**
   调用switchAudioMode可以切换音频模式。
   当调用switchAudioMode(2)时，表示当前为音频订阅模式；当调用switchAudioMode(3)时，表示当前为音频最大三方模式。
   示例代码如下：
   ```
   this.client.switchAudioMode(2)
   this.client.switchAudioMode(3)
   ```
   
 
#### API参考
[enableTopThreeAudioMode](https://support.huaweicloud.com/csdk-rtc/rtc_05_0138.html#section16)
[setVolume4TopThree](https://support.huaweicloud.com/csdk-rtc/rtc_05_0138.html#section17)
[muteAudio4TopThree](https://support.huaweicloud.com/csdk-rtc/rtc_05_0138.html#section18)
