MediaDevices.getUserMedia 中的 facesMode 在最新的 Android Chrome 中似乎不起作用?(v53)

iow*_*ame 5 javascript camera android google-chrome getusermedia

我有一个功能可以让用户选择相机并在页面上显示捕获的视频[像这样]。我的代码在 Android Google Chrome 版本 52 之前工作,但不知道为什么它现在坏了。

首先,我检查我可以使用哪些设备。

navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
  devices.forEach(function(device) {
    console.log(device.kind + ": " + device.label +
                " id = " + device.deviceId);
  });
})
.catch(function(err) {
  console.log(err.name + ": " + err.message);
});
Run Code Online (Sandbox Code Playgroud)

它像我期望的那样返回两个摄像头(一个前面,一个后面)。

videoinput:照相机1中,面向前的id = ef5f41259c805a533261c2d91c274fdbfa8a6c8d629231cb484845032f90e61a凸轮:19 videoinput:相机0,朝后的id = 81448a117b2569ba9af905d01384b32179b9d32fe6a3fbabddf03868f36e4750

然后我按照示例代码进行操作,下面是我使用的内容:

<video id="video" autoplay></video>
<script>
    var p = navigator.mediaDevices.getUserMedia({ video: {facingMode: "environment", width: 480, height: 800} });

    p.then(function(mediaStream) {
      var video = document.querySelector('video');
      video.src = window.URL.createObjectURL(mediaStream);
      video.onloadedmetadata = function(e) {
          // Do something with the video here.
      };
    });

    p.catch(function(err) { console.log(err.name); }); // always check for errors at the end.
</script>
Run Code Online (Sandbox Code Playgroud)

无论是设置facingMode: "environment"还是facingMode: {exact:"environment"},结果都是使用前置摄像头。我还应该向 Google 报告吗?