Handle multiple screen shares
By default, a session allows one screen share at a time. The host can allow several users to share simultaneously, after which each viewer chooses which share to render. For details about this feature, see Sharing multiple screens simultaneously.
Limitations
- Multiple people can share their screens at the same time, but only one screen can be rendered at a time.
- The person currently sharing their screen cannot see another person's screen share stream.
Host: enable multi-share
To let several participants share at the same time, the host enables simultaneous sharing with enableMultiShare. Any user can check the current state with isMultiShareEnabled.
let shareHelper = ZMVideoSDK.shared()?.getShareHelper()
// Host: allow multiple users to share at the same time.
shareHelper?.enableMultiShare(true)
// Anyone: check whether multi-share is currently allowed.
let multiShareEnabled = shareHelper?.isMultiShareEnabled()
ZMVideoSDKShareHelper *shareHelper = [[ZMVideoSDK sharedVideoSDK] getShareHelper];
// Host: allow multiple users to share at the same time.
[shareHelper enableMultiShare:YES];
// Anyone: check whether multi-share is currently allowed.
BOOL multiShareEnabled = [shareHelper isMultiShareEnabled];
Host: lock sharing
To prevent other participants from starting a share, the host locks sharing with lockShare. While share is locked, only the host can initiate a share. Check isShareLocked to drive the UI for non-host users.
let shareHelper = ZMVideoSDK.shared()?.getShareHelper()
// Host: lock screen sharing for everyone else.
shareHelper?.lockShare(true)
// Anyone: check the current state.
let shareLocked = shareHelper?.isShareLocked()
ZMVideoSDKShareHelper *shareHelper = [[ZMVideoSDK sharedVideoSDK] getShareHelper];
// Host: lock screen sharing for everyone else.
[shareHelper lockShare:YES];
// Anyone: check the current state.
BOOL shareLocked = [shareHelper isShareLocked];
Choose which view to display
If the local user would like to subscribe to a specific view instead of the latest view shared from the delegate callback onUserShareStatusChanged, identify the user to subscribe to, retrieve the user's share action list, and subscribe to the selected share action.
let user: ZMVideoSDKUser // The user whose screen share you want to subscribe to.
let shareActionList = user.getShareActionList()
// The shareActionList can contain 0 to multiple shares coming from the selected user.
if let shareActionList = shareActionList, shareActionList.count > 0 {
// Get the share you want to subscribe to — for example, the first share.
let shareAction = shareActionList[0]
shareAction.getShareCanvas()?.subscribe(with: yourView, aspectMode: .original, resolution: .auto)
}
ZMVideoSDKUser* user; // The user whose screen share you want to subscribe to.
NSArray* shareActionList = [user getShareActionList];
// The shareActionList can contain 0 to multiple shares coming from the selected user.
if (shareActionList.count > 0) {
// Get the share you want to subscribe to — for example, the first share.
ZMVideoSDKShareAction* shareAction = [shareActionList objectAtIndex:0];
[[shareAction getShareCanvas] subscribeWithView:yourView aspectMode:ZMVideoSDKVideoAspect_Original resolution:ZMVideoSDKResolution_Auto];
}