Created
July 5, 2015 15:10
-
-
Save soohyunc/07c96473ce5cc7e1f022 to your computer and use it in GitHub Desktop.
gUM Sample
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> | |
<h1>Simple web camera display demo</h1> | |
<video autoplay></video> | |
<script type="text/javascript"> | |
var video = document.getElementsByTagName('video')[0], | |
heading = document.getElementsByTagName('h1')[0]; | |
if(navigator.webkitGetUserMedia) { | |
navigator.webkitGetUserMedia('video', successCallback, errorCallback); | |
function successCallback( stream ) { | |
video.src = stream; | |
} | |
function errorCallback( error ) { | |
heading.textContent = | |
"An error occurred: [CODE " + error.code + "]"; | |
} | |
} else { | |
heading.textContent = | |
"Native web camera streaming is not supported in this browser!"; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment