Navigator .mediadevices.get User Media() 无法访问笔记本电脑的内置摄像头

Navigator​.mediadevices.get​User​Media() not accessing the laptops inbuilt camera

我正在开发一个用于视频录制的网络应用程序。

我试过下面的代码,但问题是它在外置摄像头上工作正常,但在笔记本电脑的内置摄像头中,使用相同的浏览器,它没有给出 Object found 错误。

我使用的是 Firefox 60.6.1

     if (navigator.mediaDevices.getUserMedia) {       
      navigator.mediaDevices.getUserMedia(constraints)
      .then(function(stream) {
    //load the stream in the video variable
        video.srcObject = stream;
    //load the stream in revokeAccess variable 
        revokeAccess=stream;
    //video playback
        video.play(); 
    /*
    Optional to avoid the dual audio disturbance. Playback audio is muted
    */
    video.muted= true;


    if (MediaRecorder.isTypeSupported('video/webm;codecs=vp9')) {
      var options = {mimeType: 'video/webm;codecs=vp9'};
      console.log("using vp9");
    } else if (MediaRecorder.isTypeSupported('video/webm;codecs=h264')) {
      var options = {mimeType: 'video/webm;codecs=h264'};
      console.log("using h264");
    } else  if (MediaRecorder.isTypeSupported('video/webm;codecs=vp8')) {
      var options = {mimeType: 'video/webm;codecs=vp8',videoBitsPerSecond : 1500000,audioBitsPerSecond : 160000};
      console.log("using vp8");
    }else{
    console.log('isTypeSupported is not supported, using default codecs for browser');
    } 

    //load the stream and type of video in the function
    mediaRecorder = new MediaRecorder(stream,options);
    //handle the data availability
    mediaRecorder.ondataavailable = handleDataAvailable;
    //Start the recording
    mediaRecorder.start(); 

    alert("Started Recording");


    //push the data into chunks(array)
    function handleDataAvailable(event) {
     if (event.data.size > 0) {
       recordedChunks.push(event.data);
        console.log(recordedChunks);
     } else {
      alert(event);
     }
    }
    //disable the Start Recording button
    document.getElementById("startRecording").disabled = true;  
      })
      .catch(function(error) {
    //handle the device not found exception
        alert("Camera not Found !! Please connect camera properly");
        console.log(error);
      });
    }

我希望应用程序能够在每个平台上运行。

您好所有开发人员感谢您的支持和快速响应。

我在代码中使用以下适配器添加解决了问题。

var getUserMedia = navigator.getUserMedia ||
navigator.mozGetUserMedia ||
navigator.webkitGetUserMedia;

如果您想支持旧版浏览器,请检查以下内容。

https://github.com/webrtcHacks/adapter

WebRTC adapter

adapter.js is a shim to insulate apps from spec changes and prefix differences. In fact, the standards and protocols used for WebRTC implementations are highly stable, and there are only a few prefixed names. For full interop information, see webrtc.org/web-apis/interop.

This repository used to be part of the WebRTC organisation on github but moved. We aim to keep the old repository updated with new releases.

此外,您可以从 firefox 检查您的硬件环境。

在浏览器的地址栏中输入以下内容

about:support