Audio

You can programmatically control user audio in an ongoing session using the methods provided by the Video SDK.

Note: Prior to using audio, you will need to request permissions to record audio. More info on how to obtain these permissions can be found here. The required Android permissions are RECORD_AUDIO.

Audio Controls

Using the SDK functions, users in a session can be provided with controls for managing their audio. Session hosts can manage their own audio as well the audio of other users in the session.

Some common features that you might want to include in your app could be an option to mute or unmute a user's audio. Prior to changing the audio control, you may also need to obtain data about the state of each users' audio and present it in the UI of your app.

Below are some examples that you can refer to when implementing features related to audio controls.

Mute or unmute a user's audio

The ZoomVideoSDKAudioHelper provides methods to manage audio of a user. Before implementing audio controls, you must first check if the user is connected to audio or not by getting the audio type of the user.

val audioStatus = user.audioStatus
val audioType = audioStatus.audioType
val audioHelper = ZoomVideoSDK.getInstance().audioHelper
ZoomVideoSDKAudioStatus audioStatus = user.getAudioStatus();
ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType audioType = audioStatus.getAudioType();
ZoomVideoSDKAudioHelper audioHelper = ZoomVideoSDK.getInstance().getAudioHelper();

If the user is not connected, you may start audio through the AudioHelper:

if (audioType == ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType.ZoomVideoSDKAudioType_None) {
    audioHelper.startAudio()
} else {
    // The user is already connected to audio.
}
if (audioType == ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType.ZoomVideoSDKAudioType_None) {
    audioHelper.startAudio();
} else {
    // The user is already connected to audio.
}

Once connected, you can mute a user's audio by calling muteAudio with the associated ZoomVideoSDKUser object:

audioHelper.muteAudio(user)
audioHelper.muteAudio(user);

A user's audio can also be unmuted in a similar manner:

audioHelper.unMuteAudio(user)
audioHelper.unMuteAudio(user);

To disconnect from audio, use the stopAudio method:

if (audioType == ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType.ZoomVideoSDKAudioType_VOIP) {
    audioHelper.stopAudio()
}
if (audioType == ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType.ZoomVideoSDKAudioType_VOIP) {
    audioHelper.stopAudio();
}

Sound options

By default, Zoom uses noise suppression and echo cancellation to improve the quality of the audio received by your microphone, but these audio filters can interfere with situations that require capturing the full range of audio. See Configuring professional audio settings for Zoom Meetings for details.

Video SDK uses the same technology to improve audio quality, but also supports the ability to turn off these filters to capture the original sound of the microphone, for example, to support the use of a high-quality microphone with built-in audio filters or to capture the full audio range without noise suppression. Capturing the microphone's original sound disables the background noise suppression feature.

Original sound

To enable original sound, set enableMicOriginalInput to true in the ZoomVideoSDKAudioSettingHelper class. The default setting is false.

ZoomVideoSDKAudioSettingHelper audioSettingHelper = ZoomVideoSDK.getInstance().getAudioSettingHelper();
audioSettingHelper.enableMicOriginalInput(true);

To disable, set enableMicOriginalInput to false.

audioSettingHelper.enableMicOriginalInput(false);

Callbacks

The following are examples of some audio callbacks.

Get notified when a user's audio status has changed

override fun onUserAudioStatusChanged(audioHelper: ZoomVideoSDKAudioHelper?, userList: MutableList<ZoomVideoSDKUser>) {
    userList.forEach {
        // Check the current user to see if they are muted
        val audioStatus = it.audioStatus
        audioStatus.isMuted
    }
}
@Override
public void onUserAudioStatusChanged(ZoomVideoSDKAudioHelper audioHelper, List<ZoomVideoSDKUser> userList) {
    for (ZoomVideoSDKUser user : userList) {
        // Check the current user to see if they are muted
        ZoomVideoSDKAudioStatus audioStatus = user.getAudioStatus();
        audioStatus.isMuted();
    }
}

Get notified when active audio changes

override fun onUserActiveAudioChanged(audioHelper: ZoomVideoSDKAudioHelper?, list: MutableList<ZoomVideoSDKUser>) {
    list.forEach {
        // Check if the current user is talking
        val audioStatus = it.audioStatus
        audioStatus.isTalking
    }
}
@Override
public void onUserActiveAudioChanged(ZoomVideoSDKAudioHelper audioHelper, List<ZoomVideoSDKUser> list) {
    for (ZoomVideoSDKUser user : list) {
        // Check if the current user is talking
        ZoomVideoSDKAudioStatus audioStatus = user.getAudioStatus();
        audioStatus.isTalking();
    }
}

Get notified when mixed audio raw data is received

override fun onMixedAudioRawDataReceived(rawData: ZoomVideoSDKAudioRawData?) {
    // See raw data documentation for more information
}
@Override
public void onMixedAudioRawDataReceived(ZoomVideoSDKAudioRawData zoomVideoSDKAudioRawData) {
    // See raw data documentation for more information
}

Get notified when one-way audio raw data is received

override fun onOneWayAudioRawDataReceived(rawData: ZoomVideoSDKAudioRawData?, user: ZoomVideoSDKUser?) {
    // See raw data documentation for more information
}
@Override
public void onOneWayAudioRawDataReceived(ZoomVideoSDKAudioRawData zoomVideoSDKAudioRawData, ZoomVideoSDKUser zoomVideoSDKUser) {
    // See raw data documentation for more information
}

Get notified when shared audio raw data is received

override fun onShareAudioRawDataReceived(rawData: ZoomVideoSDKAudioRawData?) {
    // See raw data documentation for more information
}
@Override
public void onShareAudioRawDataReceived(ZoomVideoSDKAudioRawData zoomVideoSDKAudioRawData) {
    // See raw data documentation for more information
}