在按钮上单击设备功能被调用,并应在
中显示视频 <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);
});
}
发现该代码确实有效..但是,由于我在本地网络 iPhone-> 没有 SSL 的笔记本电脑上访问它,所以会失败。
此媒体查询只能在 SSL 和没有 SSL 的本地主机上工作......
所以存在固有的问题。