Skip to content

Instantly share code, notes, and snippets.

@peterhpchen
Created March 29, 2014 07:51
Show Gist options
  • Save peterhpchen/9850333 to your computer and use it in GitHub Desktop.
Save peterhpchen/9850333 to your computer and use it in GitHub Desktop.
this is a simple demo for getUserMedia.
<!--Don't forget to add autoplay attribute-->
<video id="mediaStreamDemo" autoplay></video>
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
var constraints =
{
video: true,
audio: true
};
function success(mediaStream) {
video = document.getElementById("mediaStreamDemo");
video.src = window.URL.createObjectURL(mediaStream);
}
function error(e) {
console.log("error : " + e);
}
navigator.getUserMedia(constraints, success, error);
navigator.getUserMedia ( constraints, successCallback, errorCallback );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment