i'm doing a script to know if my browser supports the screen sharing. My Script works on every browser (Chrome, Opera, Firefox, Edge, Safari) except Internet Explorer and i don't know what is the problem.
Can you give me the answer please
var getDisplayMedia;
// Screen sharing is supported by the browser
if (navigator.mediaDevices.getDisplayMedia || navigator.getDisplayMedia){
getDisplayMedia = "O";
}else {
getDisplayMedia = "N";
}
console.log(getDisplayMedia);
On Chrome, Opera, Firefox, Edge, Safari it returns O or N. but on IE got this error : script5007 unable to get property 'getDisplayMedia' of undefined or null reference
You need to check that navigator.mediaDevices
exists before checking one of its properties.
var getDisplayMedia;
// Screen sharing is supported by the browser
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia ||
navigator.getDisplayMedia
){
getDisplayMedia = "O";
}else {
getDisplayMedia = "N";
}
console.log(getDisplayMedia);