I want to let the user share his screen, I use getDisplayMedia() to let the user start sharing and it let him choose entire screen or chrome … etc. so my question is: can I let the user always choose the entire screen, like not giving him the option of other type sharing like window … like putting constraints on it or something I tried displaySurface = 'monitor' but it didn't work
You can do work around.
You can check displaySurface,if it is not monitor(entire screen) then you can reject the promise and inside reject handler you can stop and start again.
navigator.mediaDevices
.getDisplayMedia()
.then((strm) => {
let displaySurface = strm.getVideoTracks()[0].getSettings().displaySurface;
if (displaySurface !== 'monitor') {
throw 'Selection of entire screen mandatory!';
}
})
.catch((err) => console.error(err));//Here you can stop and start again
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With