Core features

View as Markdown

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.

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()
}

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.
}

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)
}

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)
}

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()
}

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