Created
March 31, 2018 08:32
-
-
Save sheminusminus/70549332d926ae0ea93f4c31764a3920 to your computer and use it in GitHub Desktop.
webcam access
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 lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>cam</title> | |
</head> | |
<body> | |
<script> | |
const video = document.createElement('video'); | |
video.height = '500'; | |
video.width = '500'; | |
video.autoplay = 'true'; | |
document.body.appendChild(video); | |
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; | |
if (navigator.getUserMedia) { | |
navigator.getUserMedia({video: true}, handleVideo, videoError); | |
} | |
function handleVideo(stream) { | |
video.src = window.URL.createObjectURL(stream); | |
} | |
function videoError(e) { | |
console.log(e); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment