Manage in-meeting audio settings

View as Markdown

Through the SDK, 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 ZoomSDKAudioSetting, which can be accessed after the participant joins the meeting.

if let audioSetting = ZoomSDK.shared().getSettingService()?.getAudioSetting() {

}

Connect to meeting audio

Before joining a meeting, enable or disable auto connect to the meeting audio with VOIP.

audioSetting.enableAutoJoinVoip(true)

You can also update the current meeting's meeting settings to mute by default when joining the meeting, using ZoomSDKAudioSetting's enableMuteMicJoinVoip. Unless the meeting explicitly prevents participants from unmuting themselves, any client instances can override this behavior.

audioSetting.enableMuteMicJoinVoip(true)

After joining a meeting, the SDK instance may not automatically connect to the meeting audio. To send or receive audio in the meeting, connect the SDK to the audio channel.

if let myself = ZoomSDK.shared().getMeetingService()?.getMeetingActionController().getMyself() {
    if myself.getAudioType() == ZoomSDKAudioType_None {
        if let meetingService = ZoomSDK.shared().getMeetingService() {
            meetingService.getMeetingActionController().actionMeeting(with: ActionMeetingCmd_JoinVoip, userID: 0, on: ScreenType_First)
        }
    }
}

Once connected, the SDK can also disconnect from the audio channel. After disconnecting from audio, the SDK won't be able to send or receive audio until it reconnects.

if let myself = ZoomSDK.shared().getMeetingService()?.getMeetingActionController().getMyself() {
    if myself.getAudioType() == ZoomSDKAudioType_Voip {
        if let meetingService = ZoomSDK.shared().getMeetingService() {
            meetingService.getMeetingActionController().actionMeeting(with: ActionMeetingCmd_LeaveVoip, userID: 0, on: ScreenType_First)
        }
    }
}

Check whether a specific user is connected to the audio channel by checking their audio type against ZoomSDKAudioType constants. ZoomSDKAudioType_Voip means that they're connected to the meeting audio channel, ZoomSDKAudioType_Phone means that they're using audio from their phone, and ZoomSDKAudioType_None means that they aren't connected to audio.

let user: ZoomSDKUserInfo
user.getAudioType
// OR
let userAudioStatus: ZoomSDKUserAudioStatus
userAudioStatus.getType

Depending on your audio connection, you can also hide the audio dialog that appears when joining the meeting when you are not connected to audio using ZoomSDKPremeetingService.

if let preMeetingService = ZoomSDK.shared().getPremeetingService() {
    preMeetingService.disableAutoShowSelectJoinAudioDlg(whenJoinMeeting: true)
}

Managing audio speaker

Get the list of available speakers using getAudioSetting with the mic parameter as false, and check which of the speakers is selected based on its isSelectedDevice state. Then call the selectAudioDevice with the mic parameter as false to change to another speaker.

if let speakerList = audioSetting.getAudioDeviceList(false) as? [SDKDeviceInfo] {
    for device in speakerList {
        if device.isSelectedDevice() {
            print("Selected speaker: \(device.getDeviceName()) - \(device.getDeviceID())")
        }
    }
}

audioSetting.selectAudioDevice(false, deviceID: "Device_ID", deviceName: "Device_Name")

Managing audio microphone

Get the list of available speakers using getAudioSetting with the mic parameter as true, and check which of the speakers is selected based on its isSelectedDevice state. Then call selectAudioDevice with the mic parameter as true to change to another speaker.

if let microphoneList = audioSetting.getAudioDeviceList(true) as? [SDKDeviceInfo] {
    for device in microphoneList {
        if device.isSelectedDevice() {
            print("Selected mic: \(device.getDeviceName()) - \(device.getDeviceID())")
        }
    }
}
audioSetting.selectAudioDevice(true, deviceID: "Device_ID", deviceName: "Device_Name")

Mute or unmute audio

Mute the local user's audio with ZoomSDKMeetingActionController using actionMeetingWithCmd with the parameter ActionMeetingCmd_MuteAudio. Additionally, if the meeting supports participants unmuting their own audio, use the parameter ActionMeetingCmd_UnMuteAudio.

meetingService.getMeetingActionController().actionMeeting(with: ActionMeetingCmd_MuteAudio, userID: 0, on: ScreenType_First)

if meetingService.getMeetingActionController().isParticipantsUnmuteSelfAllowed() {
    meetingService.getMeetingActionController().actionMeeting(with: ActionMeetingCmd_UnMuteAudio, userID: 0, on: ScreenType_First)
}

If the current user is the meeting's host, they can mute the other meeting participants' audio. For privacy reasons, the host cannot force another participant to unmute their audio. If the user is currently muted, this code asks them to unmute their microphone.

meetingService.getMeetingActionController().actionMeeting(with: ActionMeetingCmd_MuteAudio, userID: "USER_ID", on: ScreenType_First)

The host can also mute all attendees' audio simultaneously.

// Host/co-host to mute all
meetingService.getMeetingActionController().actionMeeting(with: ActionMeetingCmd_MuteAll, userID: 0, on: ScreenType_First)

/*
 Host/co-host to ask to unmute all - This will trigger the ZoomSDKMeetingActionControllerDelegate's onHostAskUnmute callback
*/
meetingService.getMeetingActionController().actionMeeting(with: ActionMeetingCmd_UnmuteAll, userID: 0, on: ScreenType_First)

Stop incoming audio

The SDK supports stopping your device from receiving audio while staying connected to the audio channel. This lets your microphone continue capturing audio and sending it to other meeting participants, and prevents your device from playing any audio produced by others.

let meetingActionCtrl = meetingService.getMeetingActionController()
meetingActionCtrl.stopIncomingAudio(!meetingActionCtrl.isIncomingAudioStopped())