Skip to content

Instantly share code, notes, and snippets.

Created November 4, 2013 05:54
Show Gist options
  • Save anonymous/7298590 to your computer and use it in GitHub Desktop.
Save anonymous/7298590 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Getting started with WebRTC</title>
</head>
<body>
<video id="webcam"></video>
</body>
</html>
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