Created
November 29, 2012 04:09
-
-
Save arisetyo/4166764 to your computer and use it in GitHub Desktop.
webcam access
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
<video autoplay></video> | |
<script type="text/javascript"> | |
function hasGetUserMedia() { | |
// Note: Opera is unprefixed. | |
return !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia); | |
} | |
if(hasGetUserMedia()) console.log("Good to go!"); | |
else alert("boohoo... getUserMedia() is not supported in your browser.. :("); | |
var onFailSoHard = function(e) { console.log("oh no you don't!", e) }; | |
// example: using Webkit vendor | |
navigator.webkitGetUserMedia({video: true, audio: false}, function(localMediaStream) { | |
var video = document.querySelector('video'); | |
video.src = window.URL.createObjectURL(localMediaStream); | |
}, onFailSoHard); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment