getusermedia DevicesNotFoundError thrown in latest browsers

前端 未结 1 1761
小鲜肉
小鲜肉 2021-01-15 03:45

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.

相关标签:
1条回答
  • 2021-01-15 04:26

    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 */
    });
    
    0 讨论(0)
提交回复
热议问题