Aks*_*rla 2 javascript firefox google-chrome webrtc getusermedia
我一直在为WebRtc使用getUserMedia()一段时间,但自从最新的浏览器更新以来我一直无法使用它.在以前的版本工作正常.
受影响的浏览器版本Firefox - 57.0.4,Chrome - 63.0.3239.132
示例代码:
navigator.getUserMedia({ "audio": true, "video": false }, function (stream) {
console.log(stream);
localStream = stream;
},logError);
Run Code Online (Sandbox Code Playgroud)
如果有人在谷歌示例代码https://webrtc.github.io/samples/src/content/getusermedia/gum/中收到此错误,请检查此项
这个问题有什么解决方法吗?需要帮忙.谢谢
我找到了解决方案.在较新的版本中,当我们指定约束时,我们指定的约束{ audio: true, video: true }为真,需要存在相应的硬件.否则会抛出DevicesNotFoundError.
这是我使用的代码.我在本地计算机上没有网络摄像头,因此将视频指定为false.
navigator.mediaDevices.getUserMedia({ audio: true, video: false})
.then(function(stream) {
/* use the stream */
})
.catch(function(err) {
/* handle the error */
});
Run Code Online (Sandbox Code Playgroud)