Created
March 29, 2014 07:51
-
-
Save peterhpchen/9850333 to your computer and use it in GitHub Desktop.
this is a simple demo for getUserMedia.
This file contains 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
<!--Don't forget to add autoplay attribute--> | |
<video id="mediaStreamDemo" autoplay></video> |
This file contains 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
navigator.getUserMedia = navigator.getUserMedia || | |
navigator.webkitGetUserMedia || | |
navigator.mozGetUserMedia || | |
navigator.msGetUserMedia; |
This file contains 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: 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); |
This file contains 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
navigator.getUserMedia ( constraints, successCallback, errorCallback ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment