Last active
August 29, 2015 14:06
-
-
Save tokafish/0264a8d1bceb5b55f0cf to your computer and use it in GitHub Desktop.
getUserMedia
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
<!DOCTYPE html> | |
<html> | |
<head><title>getUserMedia</title></head> | |
<body> | |
<video autoplay></video> | |
<script> | |
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; | |
var constraints = { audio: false, video: true }; | |
var video = document.querySelector("video"); | |
function successCallback(stream) { | |
video.src = window.URL.createObjectURL(stream); | |
} | |
function errorCallback(error){ | |
console.log("getUserMedia error: ", error); | |
} | |
navigator.getUserMedia(constraints, successCallback, errorCallback); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment