我想使用 JS 从网络摄像头获取视频,但没有素材。
信息:
DOMException: 无法启动视频源
应用程序.js
const video = document.getElementById("video");
function startVideo() {
navigator.getUserMedia(
{
video: {}
},
stream => (video.srcObject = stream),
err => console.log(err)
);
}
startVideo();
Run Code Online (Sandbox Code Playgroud)
索引.html
...
<body>
<video id="video" width="720" height="540" autoplay muted></video>
</body>
...
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助
javascript ×1