Last active
January 15, 2018 18:33
-
-
Save cozzbie/d37bb6ea76a0e17e770550577c590979 to your computer and use it in GitHub Desktop.
WebRTC MediaStream
This file contains hidden or 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
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