Skip to content

Instantly share code, notes, and snippets.

@soohyunc
Created July 5, 2015 15:10
Show Gist options
  • Save soohyunc/07c96473ce5cc7e1f022 to your computer and use it in GitHub Desktop.
Save soohyunc/07c96473ce5cc7e1f022 to your computer and use it in GitHub Desktop.
gUM Sample
<!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