Core features

View as Markdown

The Video SDK for iOS lets you programmatically control user video during a session: check video status, start video, stop video, and render one or many users. For switching, mirroring, rotating, and other per-device camera operations, see Camera controls.

Check whether video is on

To check whether a user has their video on, read on from the user's videoStatus to get a boolean indicating whether that user's video is on in the session.

let isVideoOn = user.getVideoCanvas()?.videoStatus()?.on

Start video

Start video by calling startVideo on the ZoomVideoSDKVideoHelper. Be sure your app has camera permission before calling, or the SDK can't capture from the camera.

if let videoHelper = ZoomVideoSDK.shareInstance()?.getVideoHelper() {
    videoHelper.startVideo()
}

Stop video

Stop video by calling stopVideo on the ZoomVideoSDKVideoHelper.

ZoomVideoSDK.shareInstance()?.getVideoHelper()?.stopVideo()

Render a user's video

To render a user's video, get the user's ZoomVideoSDKVideoCanvas and subscribe a UIView to it.

// Get the user's videoCanvas.
if let usersVideoCanvas = user.getVideoCanvas() {
    // Set the video aspect.
    let videoAspect = ZoomVideoSDKVideoAspect.panAndScan
    // Subscribe the user's videoCanvas to render their video stream.
    usersVideoCanvas.subscribe(with: view, andAspectMode: videoAspect)
}

The aspect parameter controls how Zoom fits the video into the view.

TypeDescription
ZoomVideoSDKVideoAspect_OriginalDisplay video without any modifications.
ZoomVideoSDKVideoAspect_Full_FilledStretch the video to fill the canvas.
ZoomVideoSDKVideoAspect_LetterBoxAdd black bars (top/bottom or left/right) so the full frame is visible without cropping.
ZoomVideoSDKVideoAspect_PanAndScanCrop the frame to fill the canvas without bars.

For more on choosing an aspect mode and on responsive layouts, see Aspect ratio and orientation.

Remove a user's video from a canvas

When a user leaves the session, or when you want to recycle a view for a different user, unsubscribe from the canvas.

if let usersVideoCanvas = user.getVideoCanvas() {
    usersVideoCanvas.unSubscribe(with: view)
}

Render multiple users

To render multiple users at once (gallery view), iterate over the users in the session and subscribe a UIView for each. Respond to onUserJoin to add new users as they enter, and onUserLeave to unsubscribe.

func onUserJoin(_ helper: ZoomVideoSDKUserHelper?, users userArray: [ZoomVideoSDKUser]?) {
    userArray?.forEach { user in
        // Create or dequeue a UIView for this user, add it to your gallery container,
        // then subscribe the user's canvas to it.
        user.getVideoCanvas()?.subscribe(with: view, andAspectMode: .original)
    }
}

func onUserLeave(_ helper: ZoomVideoSDKUserHelper?, users userArray: [ZoomVideoSDKUser]?) {
    userArray?.forEach { user in
        // Unsubscribe and remove the corresponding view from the container.
        user.getVideoCanvas()?.unSubscribe(with: view)
    }
}

For grid layout and density recommendations, see Layout and density.