Top of pageSkip to main content

Share a UIView


This tutorial demonstrates how to use the Video SDK to share the in-app screen(single UIView) of a user in a session.

Prerequisites

  • You have integrated the Video SDK into your app and have implemented a basic video session feature. If you haven't already done so, refer to the getting started and essential guides sections to learn more.

1. Start sharing the screen

Use the startShareWithView function of the ZoomVideoSDKShareHelper to start sharing a UIView with the session.


// Get the ZoomVideoSDKShareHelper to perform UIView sharing actions.
ZoomVideoSDKShareHelper *shareHelper = [[ZoomVideoSDK shareInstance] getShareHelper];
if (shareHelper) {
    // Call startShareWithView to begin sharing.
    ZoomVideoSDKERROR returnValue = [shareHelper startShareWithView:view];
    if (returnValue == Errors_Success) {
        // Your view is now being shared.
    } else {
         // The view could not be shared.
    }
}

// Get the ZoomVideoSDKShareHelper to perform UIView sharing actions.
if let shareHelper = ZoomVideoSDK.shareInstance()?.getShareHelper() {
    // Call startShareWithView to begin sharing.
    let returnValue = shareHelper.startShare(with: view)
    if returnValue == .Errors_Success {
        // Your view is now being shared.
    } else {
        // The view could not be shared.
    }
}

Use the subscribeWithView method of the ZoomVideoSDKVideoCanvas class to subscribe to the UIView that is being shared and render it in the session.


// Get User's shareCanvas.
ZoomVideoSDKVideoCanvas *usersShareCanvas = [user getShareCanvas];
// Set video aspect.
ZoomVideoSDKVideoAspect videoAspect = ZoomVideoSDKVideoAspect_PanAndScan;
// Render the user's share stream.
[usersShareCanvas subscribeWithView:view andAspectMode:videoAspect];

// Get User's shareCanvas.
if let usersShareCanvas = user.getShareCanvas() {
    // Set video aspect.
    let videoAspect = ZoomVideoSDKVideoAspect.panAndScan
    // Render the user's share stream.
    usersShareCanvas.subscribe(with: view, andAspectMode: videoAspect)
}

2. Stop Sharing the Screen

Use the stopAppShare method of the ZoomVideoSDKShareHelper class to stop sharing the screen.


// Get the ZoomVideoSDKShareHelper to perform UIView sharing actions.
ZoomVideoSDKShareHelper *shareHelper = [[ZoomVideoSDK shareInstance] getShareHelper];
if (shareHelper) {
    // Call stopShare to stop sharing view.
    ZoomVideoSDKERROR returnValue = [shareHelper stopShare];
    if (returnValue == Errors_Success) {
        // Your view has stopped being shared.
    } else {
        // Could not stop sharing view.
    }
}

// Get the ZoomVideoSDKShareHelper to perform UIView sharing actions.
if let shareHelper = ZoomVideoSDK.shareInstance()?.getShareHelper() {
    // Call stopShare to stop sharing view.
    let returnValue = shareHelper.stopShare()
    if returnValue == .Errors_Success {
        // Your view has stopped being shared.
    } else {
        // Could not stop sharing view.
    }
}

Next Steps

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.