Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get property 'enumerateDevices' of undefined or null reference

I'm using enumerateDevices (See reference here) to get the user's camera and microphones list.

This code works great on Chrome:

$(document).ready(function(){
    navigator.mediaDevices.enumerateDevices()
    .then(gotDevices)
});

But since it's unsupported on IE, it throws an error:

Unable to get property 'enumerateDevices' of undefined or null reference

My question: Is there any alternative I can use that works across all browsers?

like image 998
Koby Douek Avatar asked Sep 16 '25 16:09

Koby Douek


1 Answers

navigator.mediadevices can also be undefined in insecure context.

You need to have https: instead of http:


There's some experiment flags on chrome to allow it:

chrome://flags/#allow-insecure-localhost

chrome://flags/#unsafely-treat-insecure-origin-as-secure

like image 128
Bhojendra Rauniyar Avatar answered Sep 19 '25 05:09

Bhojendra Rauniyar