Table of Contents
To support Screen-Sharing in the Room, you need to enable Screen-Sharing during Room Creation by setting: { "screen_share": true; })
in the JSON Payload. To receive Shared Screen, you need to subscribe to the Screen-Share Stream ID# 101 and play it on the Video Player.
Start Screen Sharing
The EnxRoom.startScreenShare()
method is used to create a Screen-Sharing Stream @ 6fps to publish in the Room. Screen Sharing continues even when the Application runs in the background.
Class: EnxRoom
Method:
EnxRoom.startScreenShare(options, Callback)
– With Web SDK v2.1.2+EnxRoom.startScreenShare(Callback)
// With Web SDK < v2.1.2
Parameters: Introduced in Web SDK v2.1.2.
options
– JSON Object. Optional. To have custom meta-data to help out UI / UX requirement, also to have many other parameters affecting Screen Share.audio
– Boolean. Default: false. To allow Screen Share to carry Audio Track from Microphone if underlying browser supports it.layout
– String. Use this to pass some value to help define UI/UX at receiving end. e.g. pass “presenter” to show a Presenter Layout with Screen Share at the receiving end.
Event Notifications:
-
share-started
– Notification to everyone in the Room when Screen-Sharing starts.
var ShareOption = { "audio": true, "layout": "presenter" /* You define this key. You may like to switch to Presenter Mode of UI at receiving end */ }; // Start Screen Share streamShare = room.startScreenShare(ShareOption, function(result){ }); // Notification to all when share starts room.addEventListener("share-started", function (event) { // Layout to switch to: event.layout // Define your UI with this key // Get Stream# 101 which carries Screen Share var shared_stream = room.remoteStreams.get(101); // Play in Player shared_stream.play("div_id", playerOptions); });
Stop Screen Sharing
The EnxRoom.stopScreenShare()
method is used to stop the ongoing Screen-Sharing.
Class: EnxRoom
Methods:
EnxRoom.stopScreenShare(sharedStream, Callback)
- Alternate way to stop screen sharing
EnxRoom.unpublish(sharedStream, Callback)
Parameter:
sharedStream
– Screen-share Stream.
Event Notification:
-
share-stopped
– Notification to everyone in the Room when Screen sharing stops.
// Stop the Shared Screen room.stopScreenShare( streamShare, function(result) { }); // Stop the Shared Screen - Alternate way room.unpublish( streamShare, function(result, error) { if (result === undefined) { // Failed } else { // Share Stopped } }); // Notification to all when share stops room.addEventListener("share-stopped", function (event) { // Handle UI here });
Error Codes / Exceptions
Code | Description |
---|---|
1143 | Device not found. Screen Share disabled at OS. |
1151 | Another Screen-Share Stream active in the Room. |
Note:
- Application Share experience may differ from browser to browser.
- Google Chrome versions below 72 need an Extension to be installed from Web Store to initiate Screen Share (at the Publisher end).
Force Stop other’s Screen Sharing
Availability: Web SDK 2.1.2+
If moderator wishes to force stop any ongoing Screen Share by other user in the Room, he can do so by using EnxRoom.stopAllSharing()
method. Note, this is Moderator exclusive feature, can’t be executed from Participant’s end point.
This method also force stops any ongoing Canvas Streaming.
Class: EnxRoom
Method: EnxRoom.stopAllSharing(Callback)
Event Notification:
-
share-stopped
– Notification to everyone in the Room when Screen sharing stops.
// Force Stop the Shared Screen room.stopAllSharing(function(result) { }); // Notification to all when share stops room.addEventListener("share-stopped", function (event) { // Handle UI here });