在mozilla Firefox浏览器中的多个摄像机之间切换

问题描述 投票:2回答:1

我有多台相机连接到我的电脑。

当我运行HTML页面时,当我从camera1切换到camera2时,我具有相机的列表。它在谷歌浏览器中运行正常。但是在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位)

OS:Ubuntu 16.04

提前感谢

javascript firefox video-streaming mozilla navigator
1个回答
0
投票

我通过更改来解决此问题

{ video: { deviceId: 'yourDeviceId' } }

to

{ video: { deviceId: { exact: 'yourDeviceId' } } }

看看这个https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

© www.soinside.com 2019 - 2024. All rights reserved.