Skip to content

Instantly share code, notes, and snippets.

@cfjedimaster
Created April 6, 2012 19:11
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 cfjedimaster/2322128 to your computer and use it in GitHub Desktop.
Save cfjedimaster/2322128 to your computer and use it in GitHub Desktop.
//a video tag
var video = document.getElementById('monitor');
//request it
navigator.webkitGetUserMedia({video:true}, gotStream, noStream);
function gotStream(stream) {
video.src = webkitURL.createObjectURL(stream);
video.onerror = function () {
stream.stop();
streamError();
};
}
function noStream() {
document.getElementById('errorMessage').textContent = 'No camera available.';
}
function streamError() {
document.getElementById('errorMessage').textContent = 'Camera error.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment