Skip to content

Instantly share code, notes, and snippets.

@tokafish
Last active August 29, 2015 14:06
Show Gist options
  • Save tokafish/0264a8d1bceb5b55f0cf to your computer and use it in GitHub Desktop.
Save tokafish/0264a8d1bceb5b55f0cf to your computer and use it in GitHub Desktop.
getUserMedia
<!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