admin管理员组

文章数量:1289392

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.

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 /

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

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.

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

Share Improve this question edited Jan 22, 2018 at 10:31 Akshay komarla asked Jan 22, 2018 at 9:54 Akshay komarlaAkshay komarla 7441 gold badge11 silver badges20 bronze badges 2
  • 2 Please post your code so we can see what causes the error.... "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers." – Reinstate Monica Cellio Commented Jan 22, 2018 at 9:56
  • example code added. – Akshay komarla Commented Jan 22, 2018 at 10:13
Add a ment  | 

1 Answer 1

Reset to default 9

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 */
});

本文标签: javascriptgetusermedia DevicesNotFoundError thrown in latest browsersStack Overflow