Skip to content

Instantly share code, notes, and snippets.

@guinso
Created August 22, 2019 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guinso/0d596e4cfe2bba480e050cd8f1d8a49a to your computer and use it in GitHub Desktop.
Save guinso/0d596e4cfe2bba480e050cd8f1d8a49a to your computer and use it in GitHub Desktop.
Example to run camera on web browser
initCamera(videoElement) {
// Grab elements, create settings, etc.
// var video = this.partial.querySelector('#video');
// Get access to the camera!
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
// Not adding `{ audio: true }` since we only want video now
navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
//video.src = window.URL.createObjectURL(stream);
videoElement.srcObject = stream;
videoElement.play();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment