Hi,
I was able to share screen successfully and it’s showing on the browser. But Unfortunately, the remote users of my Get a Room Application can’t see the published shared screen (Though, they can see me).
Need help, please.
Below is the source code.
<!-- The HTML Tag -->
<div id="session" hidden>
<div id="videos" class="row no-margin"> </div>
</div>
function getChromeVersion() {
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : false;
}
function getFirefoxVersion() {
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
return navigator.userAgent.toLowerCase().indexOf('firefox');
}
function shareMyScreen() {
if(getChromeVersion() >= 72 || getFirefoxVersion() >= 66) {
OV = new OpenVidu();
var sessionScreen = OV.initSession();
getToken().then((token) => {
sessionScreen.connect(token).then(() => {
var publisher = OV.initPublisher("videos", { videoSource: "screen" });
publisher.once('accessAllowed', (event) => {
publisher.stream.getMediaStream().getVideoTracks()[0].addEventListener('ended', () => {
console.log('User pressed the "Stop sharing" button');
});
sessionScreen.publish(publisher);
});
publisher.once('accessDenied', (event) => {
console.warn('ScreenShare: Access Denied');
});
}).catch((error => {
console.warn('There was an error connecting to the session:', error.code, error.message);
}));
});
}else{
var OV = new OpenVidu();
var publisher = OV.initPublisher('videos', { videoSource: "screen" }, function(error) {
if (error.name == 'SCREEN_EXTENSION_NOT_INSTALLED') {
showWarning(error.message);
} else if (error.name == 'SCREEN_SHARING_NOT_SUPPORTED') {
alert('Your browser does not support screen sharing');
} else if (error.name == 'SCREEN_EXTENSION_DISABLED') {
alert('You need to enable screen sharing extension');
} else if (error.name == 'SCREEN_CAPTURE_DENIED') {
alert('You need to choose a window or application to share');
}
});
}
}
BELOW IS THE CONSOLE LOG AFTER SCREEN SHARED
Event ‘accessAllowed’ triggered once by ‘Publisher’
Your local ‘Stream’ with id [undefined] video is now playing
‘Publisher’ (str_SCR_SYhW_con_PIOm9q3MwR) successfully published to session
IceConnectionState of RTCPeerConnection a57f8240-bfb9-49d0-aa55-96e5b6538790 (publisher of con_PIOm9q3MwR) change to “checking”
IceConnectionState of RTCPeerConnection a57f8240-bfb9-49d0-aa55-96e5b6538790 (publisher of con_PIOm9q3MwR) change to “connected”