为什么此代码无法在 iOS chrome 或 Safari 上使用相机,但桌面版本却可以

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

在按钮上单击设备功能被调用,并应在

中显示视频
 <video autoplay id="getVIN"></video>

但是仅适用于桌面版本的浏览器...我收到“设备”警报,但随后我在移动设备上没有收到“进行流媒体”警报...我确实在桌面版本上收到了它,并且一切正常

const constraints = 
    {
        video: {
          width: {
            min: 1280,
            ideal: 1920,
            max: 2560,
          },
          height: {
            min: 720,
            ideal: 1080,
            max: 1440
          },
          facingMode: 'user'
        }
      }


var devices = () => {
    alert('devices');
    navigator.mediaDevices.getUserMedia(constraints).then(stream => {
        alert('doing the stream');
        const stream2 = stream;
        tracks = stream2.getTracks();
        console.log('Got MediaStream:', stream);
        var video:any = document.querySelector('video');
        video.srcObject = stream2;
    })
    .catch(error => {
        alert('inhere');
        console.error('Error accessing media devices.', error);
    });
}
vuejs3 getusermedia
1个回答
0
投票

发现该代码确实有效..但是,由于我在本地网络 iPhone-> 没有 SSL 的笔记本电脑上访问它,所以会失败。

此媒体查询只能在 SSL 和没有 SSL 的本地主机上工作......

所以存在固有的问题。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.