NotReadableError: Failed to allocate videosource

混江龙づ霸主 提交于 2019-11-27 15:44:29

问题


I get this error in Firefox 51 when I try to execute the following code and when I select my laptop's camera:

navigator.getMedia = (navigator.getUserMedia ||
  navigator.webkitGetUserMedia ||
  navigator.mediaDevices.getUserMedia ||
  navigator.msGetUserMedia);

navigator.getMedia({
    video: true,
    audio: false
  },
  function(stream) {
    if (navigator.mozGetUserMedia) {
      video.mozSrcObject = stream;
    } else {
      var vendorURL = window.URL || window.webkitURL;
      video.src = vendorURL.createObjectURL(stream);
    }
    video.play();
  },
  function(err) {
    console.log("An error occured! " + err);
  }
);

Error:

NotReadableError: Failed to allocate videosource

Can someone elaborate what this means? Is my webcam broken? I used it from the script just yesterday without problems. It's not allocated to other application.


回答1:


NotReadableError is the spec compliant error thrown by Firefox when webcam access is allowed but not possible.

Most commonly this happens on Windows because the webcam is already in use by another app. Firefox will throw this error on both Windows and Mac even though only on Windows processes get exclusive access to the webcam.

The error can happen for other reasons:

Although the user granted permission to use the matching devices, a hardware error occurred at the operating system, browser, or Web page level which prevented access to the device.

Chrome throws TrackStartError instead. It also throws it for other reasons. Chrome tabs can share the same device.

Source: common getUserMedia() errors .




回答2:


Please make sure your camera is not been used by some other application (chrome, ie or any other browser). I wasted have of my day searching for a solution, and in the end, found out my camera was used by other application.




回答3:


Can someone elaborate what this means? Is my webcam broken? I used it from the script just yesterday without problems. It's not allocated to other application.

I've encountered exactly the same issue!

Shame on me! Because, in the meantime I'd added a beforeunload event, including the event.preventDefault as reported in the example.

After removing this event.preventDefault, everything worked fine - as expected.




回答4:


I've encountered same issue on Windows 10, no other apps using my video device. The problem was that in Windows 10 in Settings->App permissions (in left column) there is a setting for microphone and camera (Allow apps to access your mic/camera) which needs to be turned on. It does not matter that you don't find your browser in app list below this setting, just enable it here and voila.




回答5:


The message getUserMedia() error: NotReadableError was displayed for Chromium but not Firefox web browser. I also noticed that WebRTC examples using getUserMedia function without microphone access worked correctly in Chromium.

In fact, I had to make sure my microphone is enabled and select the correct microphone in Chromium / Chrome settings. Then WebRTC with audio and video access worked correctly.

If it is not a microphone problem, it may also be a webcam problem so you have to make sure your webcam is enabled and selected correctly in Chromium / Chrome settings.

Note that only one app at a time can use the webcam / microphone.



来源:https://stackoverflow.com/questions/42568498/notreadableerror-failed-to-allocate-videosource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!