Render a user's video


The Video SDK allows you to render the video of each user who join a session. To do so, you'll have to:

  1. Retrieve the ZoomVideoSDKUser object related to each user as they join the session.
  2. Obtain the video canvas from each user and render their video.

On This Page

Retrieve user information

The ZoomVideoSDKUserHelper helps with retrieval of user information associated with users as they join a session. See Manage User Information for more details on user management.

To be notified when users join a session, use the onUserJoin callback within ZoomVideoSDKDelegate:


- (void)onUserJoin:(ZoomVideoSDKUserHelper *)helper users:(NSArray<ZoomVideoSDKUser *> *)userArray {
    // UserArray contains the new users.
    // Use helper to perform actions on a user.
    for (int i = 0; i < userArray.count; i++) {
        NSLog(@"%@", userArray[i]);
    }
}

func onUserJoin(_ helper: ZoomVideoSDKUserHelper!, users userArray: [ZoomVideoSDKUser]!) {
    // UserArray contains the new users.
    // Use helper to perform actions on a user.
    if let userArray = userArray {
        for user in userArray {
            print(user)
        }
    }
}

For more information on implementing this delegate, refer to the Listen for Callback Events guide.

Render a user's video canvas

Now that you have access to user information represented by the ZoomVideoSDKUser object, you must retrieve the ZoomVideoSDKVideoCanvas of each user whose video you would like to render and pass a UIView into the canvas to subscribe to that user's video.


// Get User's videoCanvas.
ZoomVideoSDKVideoCanvas *usersVideoCanvas = [user getVideoCanvas];
// Set video aspect.
ZoomVideoSDKVideoAspect videoAspect = ZoomVideoSDKVideoAspect_PanAndScan;
// Subscribe User's videoCanvas to render their video stream.
[usersVideoCanvas subscribeWithView:view andAspectMode:videoAspect];

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

You can provide any of the following options to the videoAspect property in order to set the aspect mode of the video:

TypeDescription
ZoomVideoSDKVideoAspect_OriginalDisplays original video without any modifications like edit, cropping or zoom.
ZoomVideoSDKVideoAspect_Full_FilledStretches video stream to fill video canvas.
ZoomVideoSDKVideoAspect_LetterBoxFor video streams with 16:9 aspect ratios shown on a 4:3 screen, black bars will be added to the top and bottom to fit the canvas.
For video streams with a 4:3 aspect ratio shown on a 16:9 screen, black bars will be added to the left and the right to fit the canvas.
ZoomVideoSDKVideoAspect_PanAndScanFor video streams with 16:9 aspect ratios shown on a 4:3 screen, the left and right of the screen will be cropped to fit the canvas.
For video streams with 4:3 aspect ratios shown on a 16:9 screen, the top/bottom of the screen will be cropped.

Stop rendering user's video

To stop rendering a user's content, you must unsubscribe from the user's video by calling the unsubscribe() method as shown below:


// Get User's videoCanvas.
ZoomVideoSDKVideoCanvas *usersVideoCanvas = [user getVideoCanvas];
// Unsubscribe User's videoCanvas to render their video stream.
[usersVideoCanvas unSubscribeWithView:view];

// Get User's videoCanvas.
if let usersVideoCanvas = user.getVideoCanvas() {
    // Unsubscribe User's videoCanvas to render their video stream.
    usersVideoCanvas.unSubscribe(with: view)
}

Need help?

If you're looking for help, try Developer Support or our Developer Forum. Priority support is also available with Premier Developer Support plans.