Core features

The Video SDK for macOS lets you control user audio during a session: check whether a user is connected to audio, connect, mute and unmute, and disconnect. For host-level controls over everyone's audio, see Host audio controls.

Prior to using audio controls, you must request permission to use the microphone. For details, see Requesting Authorization for Media Capture on macOS.

Check if the user is connected to audio

Before you can use audio controls, check if the user is connected to audio by getting the user's ZMVideoSDKAudioType.

// Get the user's audioStatus.
if let audioStatus = user.getAudioStatus() {
    // Get the user's audioType.
    let audioType = audioStatus.getAudioType()
}
// Get the user's audioStatus.
ZMVideoSDKAudioStatus *audioStatus = [user getAudioStatus];
// Get the user's audioType.
ZMVideoSDKAudioType audioType = [audioStatus getAudioType];

Connect to audio

If the user is not already connected, connect to the audio through the ZMVideoSDKAudioHelper.

if audioType == ZMVideoSDKAudioType_None {
    // User's audio is not connected.
    // Get the ZMVideoSDKAudioHelper to perform audio actions.
    if let audioHelper = ZMVideoSDK.shared()?.getAudioHelper() {
        // Connect user's audio.
        audioHelper.startAudio()
    }
} else {
    // User is already connected to audio.
}
if (audioType == ZMVideoSDKAudioType_None) {
    // User's audio is not connected.
    // Get the ZMVideoSDKAudioHelper to perform audio actions.
    ZMVideoSDKAudioHelper *audioHelper = [[ZMVideoSDK sharedVideoSDK] getAudioHelper];
    if (audioHelper) {
        // Connect user's audio.
        [audioHelper startAudio];
    }
} else {
    // User is already connected to audio.
}

Mute audio

Once connected, mute a user's audio by calling muteAudio with the user.

// Get the ZMVideoSDKAudioHelper to perform audio actions.
if let audioHelper = ZMVideoSDK.shared()?.getAudioHelper() {
    // Mute user.
    audioHelper.muteAudio(user)
}
// Get the ZMVideoSDKAudioHelper to perform audio actions.
ZMVideoSDKAudioHelper *audioHelper = [[ZMVideoSDK sharedVideoSDK] getAudioHelper];
if (audioHelper) {
    // Mute user.
    [audioHelper muteAudio:user];
}

Unmute audio

Unmute a user's audio in a similar manner using unMuteAudio.

// Get the ZMVideoSDKAudioHelper to perform audio actions.
if let audioHelper = ZMVideoSDK.shared()?.getAudioHelper() {
    // Unmute user.
    audioHelper.unMuteAudio(user)
}
// Get the ZMVideoSDKAudioHelper to perform audio actions.
ZMVideoSDKAudioHelper *audioHelper = [[ZMVideoSDK sharedVideoSDK] getAudioHelper];
if (audioHelper) {
    // Unmute user.
    [audioHelper unMuteAudio:user];
}

Disconnect from audio

To disconnect completely from audio, use stopAudio.

// Get the ZMVideoSDKAudioHelper to perform audio actions.
if let audioHelper = ZMVideoSDK.shared()?.getAudioHelper() {
    // Disconnect user's audio.
    audioHelper.stopAudio()
}
// Get the ZMVideoSDKAudioHelper to perform audio actions.
ZMVideoSDKAudioHelper *audioHelper = [[ZMVideoSDK sharedVideoSDK] getAudioHelper];
if (audioHelper) {
    // Disconnect user's audio.
    [audioHelper stopAudio];
}

To react to audio status changes, implement the audio events.