Created
January 2, 2013 04:25
-
-
Save weisjohn/4432171 to your computer and use it in GitHub Desktop.
getUserMedia example
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>JS Bin</title> | |
</head> | |
<body> | |
<video id="sourcevid" autoplay="true">NO SUPPORT FOR VIDEO </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
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') | |
} | |
} |
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
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