Search code examples
javascriptgoogle-chromefirefoxwebrtcgetusermedia

getusermedia DevicesNotFoundError thrown in latest browsers


I have been using getUserMedia() for WebRtc for a while now but since the latest update of browsers I have not been able to use this. On previous versions worked fine.

enter image description here

Affected browsers' versions Firefox - 57.0.4 , Chrome - 63.0.3239.132

Example code:

navigator.getUserMedia({ "audio": true, "video": false }, function (stream) {
  console.log(stream);
  localStream = stream;

},logError);

Also check this if anyone is getting this error in google sample code https://webrtc.github.io/samples/src/content/getusermedia/gum/

Is there any work around for this issue? Need help. Thanks


Solution

  • I found the solution. In newer versions when we specify the constraints { audio: true, video: true } either of which ever we specify as true that corresponding hardware need to be present. otherwise it will throw DevicesNotFoundError .

    Here is the code i used. i don't have a web cam in local machine so specified video as false.

    navigator.mediaDevices.getUserMedia({ audio: true, video: false})
    .then(function(stream) {
       /* use the stream */ 
    })
    .catch(function(err) {
       /* handle the error */
    });