Skip to content

Instantly share code, notes, and snippets.

@cozzbie
Last active January 15, 2018 18:33
Show Gist options
  • Save cozzbie/d37bb6ea76a0e17e770550577c590979 to your computer and use it in GitHub Desktop.
Save cozzbie/d37bb6ea76a0e17e770550577c590979 to your computer and use it in GitHub Desktop.
WebRTC MediaStream
var constraints = { video: 1, audio: 1 },
localvid = document.querySelector("#localvid"); // A HTML5 video element with an 'autoplay' property.
// Success call
function success(stream){
localvid.src = URL.createObjectURL(stream);
}
// Failure call
function failure(e){
console.log("404!! Video failed. Whatapun!!!???", e);
}
// navigator.getUserMedia(constraints, success, failure); // Legacy code
navigator.mediaDevices.getUserMedia(constraints).then(success).catch(failure);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment