Skip to content

Instantly share code, notes, and snippets.

@szolotykh
Created December 26, 2014 16:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szolotykh/933f8009aae9fb86b161 to your computer and use it in GitHub Desktop.
Save szolotykh/933f8009aae9fb86b161 to your computer and use it in GitHub Desktop.
HTML5 Camera test
<html>
<script>
var errorCallback = function(e) {
console.log('Rejected', e);
};
function init(){
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
var video = document.querySelector('video');
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true, video: true}, function(stream) {
video.src = window.URL.createObjectURL(stream);
}, errorCallback);
} else {
alert('getUserMedia() is not supported in your browser');
}
}
</script>
<head>
</head>
<body onload = "init()">
<video autoplay></video>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment