Advanced features
Beyond the core audio controls, the Video SDK for Android offers several advanced audio features.
Monitor mic and speaker volume
The SDK reports the local microphone and speaker volume levels through the onMicSpeakerVolumeChanged callback. Use this to drive a volume meter in your UI or to detect when the mic gain has been pushed unusually low.
override fun onMicSpeakerVolumeChanged(micVolume: Int, speakerVolume: Int) {
// Volumes are reported on a 0-255 scale.
updateMicMeter(micVolume)
updateSpeakerMeter(speakerVolume)
}
@Override
public void onMicSpeakerVolumeChanged(int micVolume, int speakerVolume) {
// Volumes are reported on a 0-255 scale.
updateMicMeter(micVolume);
updateSpeakerMeter(speakerVolume);
}
Adjust a user's local volume
You can control how loud each user sounds on the local device using setUserVolume on the ZoomVideoSDKUser object. This only changes what the current user hears. It does not change the volume for any other participant in the session.
Volume is a float in the range 0 to 10. Setting it to 0 effectively mutes that user locally without muting them in the session. The second argument selects whether you are adjusting microphone audio (false) or shared audio (true, used when the user is sharing a screen with audio).
// Half-volume on a remote user's microphone audio.
if (remoteUser.canSetUserVolume(false)) {
remoteUser.setUserVolume(5.0f, false)
}
// Locally silence a noisy user without muting them for everyone.
remoteUser.setUserVolume(0f, false)
// Read the current local volume.
val currentVolume = remoteUser.getUserVolume(false)
// Half-volume on a remote user's microphone audio.
if (remoteUser.canSetUserVolume(false)) {
remoteUser.setUserVolume(5.0f, false);
}
// Locally silence a noisy user without muting them for everyone.
remoteUser.setUserVolume(0f, false);
// Read the current local volume.
float currentVolume = remoteUser.getUserVolume(false);
Use canSetUserVolume to check whether the SDK currently permits a volume change for that audio source. For example, the SDK returns false for a user who is not connected to audio.
Subscribe to raw audio data
For server-side processing, transcription, or custom audio pipelines, the SDK can deliver raw PCM audio. Call subscribe() on the ZoomVideoSDKAudioHelper to begin receiving raw audio, and unSubscribe() to stop. The mixed, per-user, and shared raw streams arrive through the onMixedAudioRawDataReceived, onOneWayAudioRawDataReceived, and onShareAudioRawDataReceived callbacks.
ZoomVideoSDK.getInstance().audioHelper.subscribe()
ZoomVideoSDK.getInstance().getAudioHelper().subscribe();
For the full raw-data integration pattern (buffer format, sample rate, and processing examples), see Receive raw data.