-
-
Save sheedy/5031553 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
</head> | |
<body> | |
<video></video> | |
<script> | |
window.addEventListener('DOMContentLoaded', function() { | |
'use strict'; | |
var video = document.querySelector('video'); | |
function successCallback(stream) { | |
if (video.mozSrcObject !== undefined) { | |
video.mozSrcObject = stream; | |
} else { | |
video.src = (window.URL && window.URL.createObjectURL(stream)) || stream; | |
} | |
video.play(); | |
} | |
function errorCallback(error) { | |
console.error('An error occurred: [CODE ' + error.code + ']'); | |
} | |
navigator.getUserMedia = | |
navigator.getUserMedia || // W3C | |
navigator.webkitGetUserMedia || // Webkit | |
navigator.mozGetUserMedia || // Mozilla | |
navigator.msGetUserMedia; // Microsoft | |
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; | |
if (navigator.getUserMedia) { | |
navigator.getUserMedia({video: true}, successCallback, errorCallback); | |
} else { | |
console.log('Native web camera streaming (getUserMedia) not supported in this browser.'); | |
} | |
}, false); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment