Created
September 1, 2013 18:20
-
-
Save jonathanhculver/6406264 to your computer and use it in GitHub Desktop.
javascript for webrtc webcam stream
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
window.onload = function() { | |
var video = document.querySelector('video'); | |
var canvas = document.querySelector('canvas'); | |
var ctx = canvas.getContext('2d'); | |
var localMediaStream = null; | |
window.URL = window.URL || window.webkitURL; | |
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || | |
navigator.mozGetUserMedia || navigator.msGetUserMedia; | |
/* creates the stream if user allows webcam to start */ | |
navigator.getUserMedia({video: true}, function(stream) { | |
video.src = window.URL.createObjectURL(stream); | |
localMediaStream = stream; | |
}, onFail); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment