Screen share stop freeze the view in remote user browser

Dear All,
I am using demo “openvidu-getaroom” code to share screen along with video. It works fine but the problem is that whenever I stop screen sharing, the screen view in remote user freezes. It seems layout is not updating at remote end but how I can detect at remote end that screen sharing has been stopped.

function shareMyScreen(){
OV = new OpenVidu();
sessionScreen = OV.initSession();
getToken(sessionId).then((token) => {
sessionScreen.connect(token).then(() => {
var publisher1 = OV.initPublisher(“videos”, {videoSource: “screen”});
publisher1.once(‘accessAllowed’, (event) => {
publisher1.stream.getMediaStream().getVideoTracks()[0].addEventListener(‘ended’, () => {
console.log(‘User pressed the “Stop sharing” button’);
numOfVideos–;
updateLayout();
});
sessionScreen.publish(publisher1);
});
publisher1.once(‘accessDenied’, (event) => {
console.warn(‘ScreenShare: Access Denied’);
});
}).catch((error => {
console.warn(‘There was an error connecting to the session:’, error.code, error.message);
}));
});
}

The user stopping the screenshare has to notify others so other participants can hide the video element.

Read the comment in this doc page:

Regards

Thanks @micael.gallego. I got your point

1 Like