getUserMedia not working on local machine

219 views Asked by At

I am trying to implement getUserMedia to use webcam. But the code is not working in local machine. I have checked it on chrome 43 on Firefox 31.

In Firefox, it is prompting request to share and after sharing in console log it is showing a message "Failure:HARDWARE_UNAVAILABLE"

In chrome it is not even asking for the permission to access webcam and no error messages or logs in console.

The same code when tried in jsfiddle is working fine and the browser able to access the camera and working fine. The following is the code:

<!DOCTYPE html>
<head>
    <title>HTML5 User Media Try Out</title>
<script>
    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; ;
    if (navigator.getUserMedia) {
        navigator.getUserMedia({video: true},loadVideo,fail);
    } else {
        console.log("User Media not defined in this browser");
    }
    function loadVideo(stream) {
        document.getElementById("video").src = window.URL.createObjectURL(stream);
    }
    function fail(failError) {
        console.log("Failure:" + failError);
    }
</script>
</head>
<body>
    <video id="video" width="640" height="480" autoplay="true"></video>
</body>
</html>

The above code is not working locally. But the same code when used in JSFiddle is just fine.

JSFiddle link: http://jsfiddle.net/7wzw7u3u/

Please help on this issue.

0

There are 0 answers