Created
November 4, 2013 05:54
-
-
Save anonymous/7298590 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Getting started with WebRTC</title> | |
</head> | |
<body> | |
<video id="webcam"></video> | |
</body> | |
</html> |
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.mozGetUserMedia || | |
navigator.webkitGetUserMedia || navigator.msGetUserMedia); | |
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; | |
if (navigator.getUserMedia) { | |
navigator.getUserMedia({ | |
video: true, | |
audio: true | |
}, onSuccess, onError); | |
} else { | |
alert('getUserMedia is not supported in this browser.'); | |
} | |
function onSuccess(stream) { | |
var video = document.getElementById('webcam'); | |
var videoSource; | |
videoSource = window.URL.createObjectURL(stream); | |
video.autoplay = true; | |
video.src = videoSource; | |
} | |
function onError() { | |
alert('There has been a problem retreiving the streams - are you running on file:/// or did you disallow access?'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment