getusermedia DevicesNotFoundError在最新的浏览器中抛出 [英] getusermedia DevicesNotFoundError thrown in latest browsers

查看:2901
本文介绍了getusermedia DevicesNotFoundError在最新的浏览器中抛出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在一直在使用getUserMedia()作为WebRtc,但自从浏览器的最新更新以来,我一直无法使用它。在以前的版本中工作正常。

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.

< img src =https://i.stack.imgur.com/4TwIs.pngalt =此处输入图片说明>

受影响的浏览器'版本
Firefox - 57.0.4,
Chrome - 63.0.3239.132

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);

如果有人在google示例代码中得到这个错误
https://webrtc.github.io/samples/src/content/getusermedia/gum/

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

推荐答案

我找到了解决方案。在新版本中,当我们指定约束 {audio:true,video:true} 时,我们将其中的任何一个指定为true,以至于需要存在相应的硬件。否则它会抛出 DevicesNotFoundError

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 .

这是我使用的代码。

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

这篇关于getusermedia DevicesNotFoundError在最新的浏览器中抛出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆