Skip to content

Instantly share code, notes, and snippets.

@octosteve
Created June 9, 2016 15:11
Show Gist options
  • Save octosteve/7c6b5ae36308f62cc8031cc5c3f17033 to your computer and use it in GitHub Desktop.
Save octosteve/7c6b5ae36308f62cc8031cc5c3f17033 to your computer and use it in GitHub Desktop.
// function showVideo(localMediaStream) {
// var video = document.querySelector('video');
// video.src = window.URL.createObjectURL(localMediaStream);
// }
//
// navigator.webkitGetUserMedia({video: true, audio: true}, function(localMediaStream) {
// showVideo(localMediaStream)
// }, function(e){
// console.log("Noooope");
// });
var webCamPromise = new Promise(function(resolve, reject) {
navigator.webkitGetUserMedia({video: true, audio: true}, function(localMediaStream) {
resolve(localMediaStream)
}, function(e){
reject(e)
})
});
webCamPromise.then(function(localMediaStream){
var video = document.querySelector('video');
video.src = window.URL.createObjectURL(localMediaStream);
}).catch(function(e){
console.log("Kabooom")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment