网络摄像头不工作,因为视频不显示?

Webcam not working because the video not showing up?

为什么我的视频没有出现,但顶部有录制图像?

    <h1 style="margin-bottom:10px;">Access WebCam using JavaScript</h1>
    <video id="video" autoplay>Not supported in your browser</video>
    </center>
  <script>
    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
    if(navigator.getUserMedia){
      navigator.getUserMedia({video:true},handleVideo,videoError);
    }

    function handleVideo(stream){
      document.querySelector('#video').src = window.URL.createObjectURL(stream);
    }

    function videoError(e){
      alert('Something is wrong');
    }
  </script>

内部 handleVideo 函数更改为:

document.querySelector('#video').srcObject  = stream;

对我有用。