Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<body onload="init();">
  <html>
<video id="output" width="400" height="400" autoplay>Put your fallback message here.</video>
<canvas id="myCanvas" width=400 height=400></canvas>
  
<script>
    var is_mozilla = false;
    var is_webkit = false;
    var video  = document.getElementById('output');
 
    function onSuccess(stream) {
        var source;
        if (!is_webkit) {
            source = stream;
        }
        else {
            source = window.webkitURL.createObjectURL(stream);
        }
        if (is_mozilla) {
            video.mozSrcObject = source;
        } else {
             video.src = source;
        }
    }
    function onError() {
        alert('getUserMedia API not supported, or another application is using the webcam !');
    }
    if (navigator.mozGetUserMedia) {
        is_mozilla = true;
        navigator.mozGetUserMedia({video:true, audio:false}, onSuccess, onError);
    }
    else if (navigator.getUserMedia) {
        navigator.getUserMedia({video:true, audio:false}, onSuccess, onError);
    }
    else if (navigator.webkitGetUserMedia) {
        is_webkit = true;
        navigator.webkitGetUserMedia({video:true, audio:false}, onSuccess, onError);
    }
</script>
    </html>
</body>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
MichelBuffapro
0viewers