我正在尝试使用getUserMedia将摄像头实时流显示在网页上。它可以正常工作(如果我将流保存到文件中,它是好的),但视频标签仅显示静态绿色图像作为预览。有人遇到同样的问题吗?
我的设置:
- 三星S8(SM-G950F)
- Android 9
- Chrome 107.0.5304.91
HTML
<video autoplay="true" width="100%" id="video-test"></video>
JS
var video = document.querySelector("#video-test");
navigator.mediaDevices.getUserMedia({
video: {
mandatory: { minFrameRate: 10, minWidth: 100, minHeigth: 100 },
}
})
.then(function (stream) {
video.srcObject = stream;
})
.catch(function (err0r) {
console.log("Something went wrong!", err0r);
});
谢谢