Manage in-meeting audio settings
The code on this page works with either the default UI or the custom UI.
Let individual users manage their own various audio settings and control their in-meeting audio state. Additionally, meeting hosts can manage settings for other users and for the meeting as a whole.
Most of the functionality is done through InMeetingAudioController, which can be accessed after the participant joins the meeting.
val audioController = ZoomSDK.getInstance().inMeetingService.inMeetingAudioController
InMeetingAudioController audioController = ZoomSDK.getInstance().getInMeetingService().getInMeetingAudioController();
Connect to meeting audio
After joining a meeting, the SDK instance may not be automatically connected to the meeting audio. To send or receive audio in the meeting, the SDK must connect to the audio channel.
if (!audioController.isAudioConnected) {
audioController.connectAudioWithVoIP()
}
if (!audioController.isAudioConnected) {
audioController.connectAudioWithVoIP();
}
Once connected, the SDK can also disconnect from the audio channel. After disconnecting from audio, the SDK will no longer be able to send or receive audio until it reconnects.
if (audioController.isAudioConnected) {
audioController.disconnectAudio()
}
if (audioController.isAudioConnected) {
audioController.disconnectAudio();
}
You can also check whether a specific user is connected to the audio channel by checking their audio type against InMeetingSupportAudioType constants.
AUDIO_TYPE_VOIPmeans that they're connected to the meeting audio channel.AUDIO_TYPE_TELEPHONYmeans that they're using audio from their phone.AUDIO_TYPE_NONEmeans that they are not connected.
user.audioStatus.audioType
long type = user.getAudioStatus().getAudioType();
Depending on your audio connection, you may also choose to hide the audio dialog that appears after joining the meeting when users aren't connected to audio.
val meetingSettingsHelper = ZoomSDK.getInstance().meetingSettingsHelper
meetingSettingsHelper.disableAutoShowSelectJoinAudioDlgWhenJoinMeeting(true)
MeetingSettingsHelper meetingSettingsHelper = ZoomSDK.getInstance().getMeetingSettingsHelper();
meetingSettingsHelper.disableAutoShowSelectJoinAudioDlgWhenJoinMeeting(true);
Switch the audio output
To switch between the earpiece and speaker, check if the current device supports switching and then call setLoudSpeakerStatus.
if (audioController.canSwitchAudioOutput()) {
audioController.loudSpeakerStatus = true
}
if (audioController.canSwitchAudioOutput()) {
audioController.setLoudSpeakerStatus(true);
}
Mute or unmute audio
Mute the local user's audio with muteMyAudio. Additionally, if the meeting supports participants unmuting their own audio after it was muted by a host, do that by using the muteMyAudio method.
audioController.muteMyAudio(true)
if (audioController.canUnmuteMyAudio()) {
audioController.muteMyAudio(false)
}
audioController.muteMyAudio(true);
if (audioController.canUnmuteMyAudio()) {
audioController.muteMyAudio(false);
}
If the current user is the host of a meeting, they can mute the other participants' audio.
For privacy reasons, the host cannot force another participant to unmute their audio. If the user is currently muted, this code will ask them to unmute their microphone.
audioController.muteAttendeeAudio(!user.audioStatus.isMuted, userId)
audioController.muteAttendeeAudio(!user.getAudioStatus().isMuted(), userId);
The host can also simultaneously mute all attendees' audio.
audioController.muteAllAttendeeAudio(true)
audioController.muteAllAttendeeAudio(true);
Update the meeting settings of the current meeting to mute by default upon joining the meeting. Unless the meeting explicitly prevents participants from unmuting themselves, any client instances can override this behavior
audioController.setMuteOnEntry(true)
audioController.setMuteOnEntry(true);
Stop incoming audio
The SDK supports stopping your device from receiving audio while staying connected to the audio channel. This allows your microphone to continue capturing audio and sending it to other meeting participants and will prevent your device from playing any audio produced by others.
audioController.stopIncomingAudio(!audioController.isIncomingAudioStopped)
audioController.stopIncomingAudio(!audioController.isIncomingAudioStopped());