Rate this page:

How to Share Screen

Voximplant allows sharing the screen during video calls to provide advanced collaboration experience for participants. This feature is available in web/mobile clients built upon Voximplant SDKs; learn more about the limitations of screen sharing and how to make it work in this article.

Limitations

  • Web: it works in Chrome and Firefox as they both have native support of screen sharing.
  • iOS: minimum supported version is 11.
  • iOS: screen sharing outside the application is only available via broadcast sharing.
  • Android: minimum supported version is 21.

Before You Start

Connected calls only

Screen sharing is available only in connected calls, e.g., after the onCallConnected event is triggered. See the details in this how-to.

You have to check if screen sharing is possible at the moment. In the Web SDK, there is a screenSharingSupported method that allows doing it.

screenSharingSupported

screenSharingSupported

Start Sharing

Web SDK

In the Web SDK, screen sharing is started by calling the shareScreen method which has two parameters, showLocalView and replaceVideo.

call.shareScreen(showLocalView, replaceVideo)

The showLocalView parameter set to true creates a screen sharing preview visible locally in the same way as it's done for video calls. It is false by default.

If a user was sending video before activation of the screen sharing, replaceVideo=true will replace the video with screen sharing; otherwise, the screen sharing stream will appear next to the video that another participant is receiving.

This is how screen sharing affects local video:

  • showLocalView=true, replaceVideo=false – the screen sharing stream will appear next to the local video.
  • showLocalView=true, replaceVideo=true and showLocalView=false, replaceVideo=true – local video will be replaced with sharing.

Note that if the local video was stopped before activation of the screen sharing, the replaceVideo parameter will not affect the local video in any way.

Browser policy

IMPORTANT: Safari browser for iOS and Chrome browser for macOS require a user interface for playing a video during a call. It should be an interactive element like an HTML "button" with the "onclick" handler that calls the "play" method on the "video" HTML element. Read these two articles for more details:

1) Autoplay Policy Changes

2) Auto-Play Policy Changes for macOS

The WebSDK starts playing videos automatically, but sometimes it doesn't work due to browser policy. The Events.PlaybackError event helps us keep track that the video has not started.

Events.PlaybackError

Events.PlaybackError

shareScreen

shareScreen

Android SDK

Screen sharing for Android is implemented via the Android MediaProjection API

Before starting screen sharing, you need to request user permission for it by creating an Intent via the MediaProjectionManager.createScreenCaptureIntent API, then call the startActivityForResult API.

Hence, screen sharing will start only if a user gave permission for this action.

createScreenCaptureIntent

createScreenCaptureIntent

To start screen sharing, you need to call the ICall.startScreenSharing API and pass to it the created Intent.

You can always check if sharing is started or not via ICallCompletionHandler; in case of success, the ICallCompletionHandler.onComplete will be called, otherwise, the ICallCompletionHandler.onFailure method will be called with the code error in CallException. See all the error codes in the CallError enum.

startScreenSharing

startScreenSharing

iOS SDK

Only in-app sharing

The following instructions related to the in-app screen sharing only. For screen sharing outside the application, use the Broadcast sharing.

Call the VICall.startInAppScreenSharing method, this will lead to a standard iOS security prompt whether a user allows or not performing the action. A user's decision is not saved between application launches.

startInAppScreenSharing

startInAppScreenSharing

Stop Sharing

Web SDK

To stop sharing the screen immediately, use the stopSharingScreen method. It will stop sharing for all windows/screens.

stopSharingScreen

stopSharingScreen

Android SDK

In order to stop screen sharing, use the ICall.sendVideo method. If the first argument is true, screen sharing will stop and the application will start capturing and sending video; otherwise, screen sharing will stop and no video will be captured/sent.

sendVideo

sendVideo

iOS SDK

To stop the in-app screen sharing, you need to call the VICall.setSendVideo method. If the first argument is true, screen sharing will stop and the application will start capturing and sending video; otherwise, screen sharing will stop and no video will be captured/sent.

setSendVideo

setSendVideo