admin管理员组文章数量:1352788
I've been experimenting with webRTC for my next project to create a video chat and testing has been difficult. I have this simple code to access the camera:
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
var video = document.querySelector('#av-chat video');
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true, video: true}, function(stream) {
video.src = window.URL.createObjectURL(stream);
}, errorCallback);
}
which works fine on chrome and mozilla but when I try to do it together, it doesn't work. What I mean by together is like opening the same file with this code in two browsers. It seems that when one browser has access to the camera, it blocks it for anyone else.
I have not seen this issue discussed on the internet so I was wondering, is it just me? If not, is there a solution?
I've been experimenting with webRTC for my next project to create a video chat and testing has been difficult. I have this simple code to access the camera:
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
var video = document.querySelector('#av-chat video');
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true, video: true}, function(stream) {
video.src = window.URL.createObjectURL(stream);
}, errorCallback);
}
which works fine on chrome and mozilla but when I try to do it together, it doesn't work. What I mean by together is like opening the same file with this code in two browsers. It seems that when one browser has access to the camera, it blocks it for anyone else.
I have not seen this issue discussed on the internet so I was wondering, is it just me? If not, is there a solution?
Share Improve this question asked Apr 9, 2017 at 13:20 WhipWhip 2,24426 silver badges50 bronze badges 1- 2 It's really not surprising that things would work that way. – Pointy Commented Apr 9, 2017 at 13:21
3 Answers
Reset to default 7This is a limitation on Windows. On Mac OS you can use the same camera in multiple applications at the same time but not in Windows unfortunately. You have a few options here:
- Buy a Mac
本文标签: javascriptgetUserMediaCannot access camera from two browsers at the same timeStack Overflow
版权声明:本文标题:javascript - getUserMedia - Cannot access camera from two browsers at the same time - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743920583a2562014.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论