Skip to content

Instantly share code, notes, and snippets.

@SimonGivre
Created October 4, 2012 23:22
Show Gist options
  • Save SimonGivre/3837087 to your computer and use it in GitHub Desktop.
Save SimonGivre/3837087 to your computer and use it in GitHub Desktop.
JS Webcam fun
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || undefined;
navigator.getUserMedia({video: true}, function (stream) {
window.webcamSwiperStream = stream;
var videoElement = document.createElement("video");
videoElement.autoplay = true;
document.getElementsByTagName("body")[0].appendChild(videoElement);
if (window.URL === undefined) {
window.URL = window.webkitURL;
}
videoElement.src = window.URL.createObjectURL(stream);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment