Created
June 3, 2017 18:05
-
-
Save leonardokl/40ecfd90518ebfa37d590125ecf7b448 to your computer and use it in GitHub Desktop.
Display Webcam Stream
This file contains hidden or 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> | |
<title>Display Webcam Stream</title> | |
<style> | |
body { | |
margin: 0; | |
} | |
#webcam { | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
background-color: #111; | |
} | |
</style> | |
</head> | |
<body> | |
<video autoplay="true" id="webcam"> | |
<script> | |
let $video = document.querySelector("#webcam") | |
navigator.mediaDevices.getUserMedia({ video: { facingMode: "user" } }) | |
.then(window.URL.createObjectURL) | |
.then(url => $video.src = url) | |
.catch(console.error) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment