Live SDKs JavaScript v1
Live SDKs JavaScript
Live SDKs
JavaScript
Version 1
The screen sharing function allows a host to share their screen during a live event. The host can select a specific app or window on their device and share it while media streaming.
This function is especially useful for showing demonstrations, presentations or any other application that requires sharing the host's screen.
A host can start screen share by calling startScreenShare()
as shown below. When the host starts sharing the screen, a dialog box will appear to ask the host to grant permissions to share the selected app or window. The host's video view will lay on top of the shared screen and the host can choose where to place their own video view.
/*
export declare enum CameraOverlayPosition {
'TOP_LEFT' = 'top_left',
'TOP_RIGHT' = 'top_right',
'BOTTOM_LEFT' = 'bottom_left',
'BOTTOM_RIGHT' = 'bottom_right',
'HIDDEN' = 'hidden',
}
export declare interface ScreenShareOptions {
cameraOverlayPosition: CameraOverlayPosition;
frameRate: number;
}
*/
const options = {
cameraOverlayPosition: CameraOverlayPosition.TOP_LEFT,
frameRate: 24
};
try {
await liveEvent.startScreenShare(options);
} catch (e) {
// handle error.
}
The host can stop screen share by calling stopScreenShare()
as shown below. When screen share ends, the video stream will switch back to the host's video view.
try {
liveEvent.stopScreenShare();
} catch (e) {
// handle error.
}
The host can set the screen share options by calling setScreenShareOptions()
as shown below. This method can be called either before or during the screen sharing.
/*
export declare enum CameraOverlayPosition {
'TOP_LEFT' = 'top_left',
'TOP_RIGHT' = 'top_right',
'BOTTOM_LEFT' = 'bottom_left',
'BOTTOM_RIGHT' = 'bottom_right',
'HIDDEN' = 'hidden',
}
export declare interface ScreenShareOptions {
cameraOverlayPosition: CameraOverlayPosition;
frameRate: number;
}
*/
const options = {
cameraOverlayPosition: CameraOverlayPosition.BOTTOM_RIGHT,
frameRate: 12
};
liveEvent.setScreenShareOptions(options);