Interact with screen sharing
The code on this page works with either the default UI or the custom UI.
Users in a meeting can share the contents of their screens to the rest of the meeting,
and view content in real time shared by other users. To manage screen sharing
functionality, use the InMeetingShareController.
val screenShareController = ZoomSDK.getInstance().inMeetingService.inMeetingShareController
InMeetingShareController screenShareController = ZoomSDK.getInstance().getInMeetingService().getInMeetingShareController();
Share your screen
Check whether you can start sharing before calling the startShareScreenSession method.
val reasonType =
ZoomSDK.getInstance().inMeetingService.inMeetingShareController.canStartShare()
if (reasonType != CannotShareReasonType.CannotShareReasonType_None) {
// Not able to start sharing
}
CannotShareReasonType reasonType = ZoomSDK.getInstance().getInMeetingService().getInMeetingShareController().canStartShare();
if (reasonType != CannotShareReasonType.CannotShareReasonType_None) {
// Not able to start sharing
}
To share your screen, choose the share type that best fits your use case.
- Share the whole screen - Capture the whole screen from the device that is sharing.
- Share a single view - Define a
MobileRTCShareViewsurrounding the content you want to share.
To know when a user's share status changes, use the onSharingStatus callback.
val shareListener = object : InMeetingShareListener {
override fun onSharingStatus(status: SharingStatus?, userId: Long) {
// Respond to changes in share status here
}
...
}
screenShareController.addListener(shareListener)
InMeetingShareController.InMeetingShareListener shareListener = new InMeetingShareController.InMeetingShareListener() {
@Override
public void onSharingStatus(SharingStatus sharingStatus, long userId) {
// Respond to changes in share status here
}
...
};
screenShareController.addListener(shareListener);
Sharing the whole screen requires more setup, since the Android system relies on an Intent
from the MediaProjectionManager. To request permission from the end user to capture their
screen's contents, create this Intent and pass it into the SDK. You also need ACTION_MANAGE_OVERLAY_PERMISSION
for displaying the sharing tool bar.
val mediaProjectionManager = activity.getSystemService(Context.MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
val mediaProjectionIntent = mediaProjectionManager.createScreenCaptureIntent()
screenShareController.startShareScreenSession(mediaProjectionIntent)
MediaProjectionManager mediaProjectionManager = activity.getSystemService(Context.MEDIA_PROJECTION_SERVICE);
Intent mediaProjectionIntent = mediaProjectionManager.createScreenCaptureIntent();
screenShareController.startShareScreenSession(mediaProjectionIntent);
View another user's screen share
Use a MobileRTCVideoView instance to subscribe to a user's share feed. Once another
user's share is visible as indicated by the Sharing_View_Other_Sharing status in
onSharingStatus, render the screen share with addShareVideoUnit.
val renderInfo = MobileRTCRenderInfo(0, 0, 100, 100) // Sample render info
videoView.videoViewManager.addShareVideoUnit(userId, renderInfo)
MobileRTCRenderInfo renderInfo = new MobileRTCRenderInfo(0, 0, 100, 100); // Sample render info
videoView.getVideoViewManager().addShareVideoUnit(userId, renderInfo);
Unsubscribe from the share data when a user stops their share, when
Sharing_Other_Share_End is received in onSharingStatus.
videoView.videoViewManager.removeShareVideoUnit()
videoView.getVideoViewManager().removeShareVideoUnit();
Manage share settings
To control most of the in-meeting share settings, use MeetingSettingsHelper.
val meetingSettingsHelper = ZoomSDK.getInstance().meetingSettingsHelper
MeetingSettingsHelper meetingSettingsHelper = ZoomSDK.getInstance().getMeetingSettingsHelper();
To toggle whether a green border will surround the content being shared by this
device, use enableGreenBorderForShareScreen.
meetingSettingsHelper.enableGreenBorderForShareScreen(true)
meetingSettingsHelper.enableGreenBorderForShareScreen(true);
When annotation is enabled, the default annotation toolbar is displayed. To hide or replace
the default annotation toolbar and replace it with a custom annotation toolbar, use
hideAnnotationInScreenShareToolbar to disable the annotation UI when you start
sharing your screen.
meetingSettingsHelper.hideAnnotationInScreenShareToolbar(true)
meetingSettingsHelper.hideAnnotationInScreenShareToolbar(true);
The default overlay has a button that the end user can select to end their screen share. Toggle this
with hideStopShareInScreenShareToolbar.
meetingSettingsHelper.hideStopShareInScreenShareToolbar(true)
meetingSettingsHelper.hideStopShareInScreenShareToolbar(true);
In addition to the toolbar overlay, the SDK shows a video tile with the active speaker when a
share starts. To toggle this view's visibility, use setNoVideoTileOnShareScreenEnabled.
meetingSettingsHelper.isNoVideoTileOnShareScreenEnabled = true
meetingSettingsHelper.setNoVideoTileOnShareScreenEnabled(true);
To toggle whether your video will automatically turn off when you start sharing your screen,
use setVideoOnWhenMyShare.
meetingSettingsHelper.setVideoOnWhenMyShare(true)
meetingSettingsHelper.setVideoOnWhenMyShare(true);