Skip to content

Instantly share code, notes, and snippets.

@weisjohn
Created January 2, 2013 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weisjohn/4432171 to your computer and use it in GitHub Desktop.
Save weisjohn/4432171 to your computer and use it in GitHub Desktop.
getUserMedia example
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<video id="sourcevid" autoplay="true">NO SUPPORT FOR VIDEO </video>
</body>
</html>
window.onload = function() {
var video = document.getElementById('sourcevid');
if (navigator.getUserMedia) {
navigator.getUserMedia('video', successCallback, errorCallback);
function successCallback(stream) {
video.src = stream;
console.log('video stream success!');
}
function errorCallback(error) {
console.error('An error occurred: [CODE ' + error.code + ']');
return;
}
}
else {
alert('No support for getUserMedia in your browser')
}
}
video {
position:absolute;
left:100px;
top:100px;
border-radius:20px;
box-shadow: 10px 10px 10px rgba(68,68,68,0.6);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment