NotReadableError: Failed to allocate videosource

前端 未结 7 1557
逝去的感伤
逝去的感伤 2020-12-30 22:57

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 |         


        
相关标签:
7条回答
  • 2020-12-30 23:29

    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.

    0 讨论(0)
  • 2020-12-30 23:30

    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.

    0 讨论(0)
  • 2020-12-30 23:31

    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.

    0 讨论(0)
  • 2020-12-30 23:36

    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 .

    0 讨论(0)
  • 2020-12-30 23:38

    If you are here after or in December 2019 i would like to tell you few things

    1. This feature navigator.getUserMedia() is deprecated.
    2. Successor of this feature in the browsers will be window.navigator.mediaDevices.getUserMedia.
    3. The new feature may not support in many browsers, since its still in the experiment mode few days ago chrome released its chrome 79 and its still not supporting in chrome 79 for me, and other than chrome and IE its working in all the browsers for me
    4. Here is a quick code

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Jello</title>
        <style>
            video{
                width: 30%;
                height: auto;
            }
        </style>
    </head>
    <body>
        <video autoplay controls></video>
        <button>Open Cam</button>
        <script>
        function getCam(){
            window.navigator.mediaDevices.getUserMedia({video:true}).then((stream)=>{
                // let videoTrack = stream.getVideoTracks()[0];
                // console.log(videoTrack);
                document.querySelector("video").srcObject = stream;
            }).catch(err=> console.log(err.name))
        }
        // getCam();
        document.querySelector("button").addEventListener("click", getCam);
        </script>
    </body>
    </html>

    Edit => if you are using in windows 10 make sure give chrome access your microphone and camera, otherwise it won't work

    0 讨论(0)
  • 2020-12-30 23:46

    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.

    0 讨论(0)
提交回复
热议问题