Suppose two users is already connected in room. Both are sharing own video.
If user A will start screen share, then B is not able to see the screen of A. still showing the video of A but not showing the screen of A.
When B will refresh the page, then he can see the screen of A or If any new user will come in this group then he can see the screen of A. Existing users not able to see of screen of A.
Following I am sharing of screen sharing code.
async function screenSharing() {
// alert(“screenSharing”);
// get a screen share track
localScreen = await navigator.mediaDevices.getDisplayMedia({
video: true,
audio: true
});
let element = document.getElementById("local_video");
element.srcObject = localScreen;
// // create a producer for video
videoProducer = await producerTransport.produce({
track: localScreen.getVideoTracks()[0],
encodings: screenshareEncodings(),
codec : device.rtpCapabilities.codecs
.find((codec) => codec.mimeType.toLowerCase() === 'video/vp8'),
appData: { mediaTag: 'screen-video' }
});
//create a producer for audio, if we have it
if (localScreen.getAudioTracks().length) {
audioProducer = await producerTransport.produce({
track: localScreen.getAudioTracks()[0],
appData: { mediaTag: 'screen-video' }
});
}}