我的电脑上连接了多个摄像头。
当我运行我的超文本标记语言页面时,我有相机的列表,当我从camera1切换到camera2时,它在谷歌chrome浏览器中工作得很好。但在Firefox中,我无法更改本地视频标签的流。
这是我用chrome编写的工作代码。
// This is My HTML tag
<video id="s-video" height="20%" width="15%" class="sub_video" autoplay="autoplay"></video>
// Javascript code
navigator.mediaDevices.getUserMedia({video: {deviceId: camera}})
.then(function(stream) {
// I also get camera ID Hear in alert
// svideo is video tag with autoplay enabled
svideo = document.getElementById('s-video');
svideo.srcObject = stream;
});现在,这段代码可以在chrome中运行,但是当我在Firefox浏览器中运行这个页面时,即使我从Firefox的权限标签中选择了一个摄像头,它也不会改变流。
我的Firefox版本是: Firefox Quantum 64.0b11 (64位)
操作系统: Ubuntu 16.04
提前感谢
发布于 2020-05-10 18:44:25
我通过改变来解决这个问题
{ video: { deviceId: 'yourDeviceId' } }至
{ video: { deviceId: { exact: 'yourDeviceId' } } }看一下这个https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
https://stackoverflow.com/questions/53850000
复制相似问题