<video onloadedmetadata="" id="inputVideo" style=" 1080px;height: 861.97px" autoplay muted playsinline></video>
<javascript>
const promise = navigator.mediaDevices.getUserMedia({ video: {} })
//获取异常
promise.catch(function(MediaStream) {
alert('摄像头未开启或浏览器无法打开摄像头')
return
});
// 获取视频流
const stream = await navigator.mediaDevices.getUserMedia({ video: {} })
const videoEl = $('#inputVideo').get(0)
videoEl.srcObject = stream
</javascript>