Created
April 6, 2012 19:11
-
-
Save cfjedimaster/2322128 to your computer and use it in GitHub Desktop.
This file contains 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
//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