Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<h4>Simple web camera display</h4>
<video id="output" width="400" height="400" autoplay>Put your fallback message here.</video>
  
<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>
 
if (document.getElementById('hello')) {
  document.getElementById('hello').innerHTML = 'Hello World - this was inserted using JavaScript';
}
Output

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

Dismiss x
public
Bin info
MichelBuffapro
0viewers