A Client End Point can start a Screen-Share using window.EnxRtc.addScreenShare() method. The method creates a stream of Mobile Screen @ 6fps to publish to the Room.  window.EnxRtc.removeScreenShare() method stops the ongoing Screen Share. Screen Share continues even when the Application goes into the background.

When a user starts or stops Screen Share, all connected users of the room are notified with onScreenSharedStarted and onScreenSharedStopped listeners. As Screen-Share is also a Stream, you can play it using a Video Player. Screen Share is carried on Stream ID# 101. Client End Point must subscribe to this Stream ID to receive and play it locally.

Note: You need to enable screen share while defining a room with 

{ "settings": { "screen_share": true; }) in JSON Payload. Know more…

Method: addScreenShare( viewOptions, successCallback, errorCallback )

Parameters:

  • @param {JSON} viewOptions – Contains display attributes as given below:
    • height
    • width
    • margin_top
    • margin_left
    • margin_right
    • margin_bottom
    • position
  • @param {SuccessCallback}
  • @param {ErrorCallback}

Event Listener:

onScreenSharedStarted – All the participants are notified that screen sharing has started. To show the shared screen in the room, call the addScreenShare() method inside this event listener.

// Add event Listener to listen screen shared started in the roomwindow.EnxRtc.addEventListner("onScreenSharedStarted",
function (data)
{
console.log(JSON.stringify(data.data));
addScreenShare(); // Add Screen Share
});

// To Add Screen Share
var options = {
height: 130,
width: 100,
margin_top: 50,
margin_left: 0,
margin_right: 15,
margin_bottom: 10,
position: "top"
};
window.EnxRtc.addScreenShare(options, function (data) {
console.log('Excelsior succuss! ' + JSON.stringify(data.data));
}, function (err) {
console.log('Uh oh… error' + JSON.stringify(err));
});

Method: removeScreenShare( successCallback, errorCallback )

Parameters:

  • @param {CallableFunction} successCallback
  • @param {CallableFunction} errorCallback

Event Listener:

onScreenSharedStopped – All the participants are notified that screen sharing has stopped. To remove the shared screen from the room, call the removeScreenShare() method inside this event listener.

// Add event Listener to listen screen shared stopped in the room
window.EnxRtc.addEventListner("onScreenSharedStopped",
function (data)
{
console.log(JSON.stringify(data.data));
removeScreenShare(); // Stop Screen Share
});

// To Remove Screen Share
window.EnxRtc.removeScreenShare(function (data) {console.log('Excelsior succuss! ' + JSON.stringify(data.data));
}, function (err) {
console.log('Uh oh… error' + JSON.stringify(err));
});