Created
October 27, 2019 16:43
-
-
Save gjj/2e94bf31a206ea506ff35e1efbae2634 to your computer and use it in GitHub Desktop.
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
<button onclick="start()">Start!</button><br /> | |
<video id="v" autoplay playsinline></video> | |
<script type="text/javascript"> | |
var config = { | |
video: { | |
width: 1280, | |
facingMode: { | |
exact: "environment" | |
} | |
} | |
}; | |
var start = () => navigator.mediaDevices.getUserMedia(config) | |
.then(stream => { | |
currentStream = stream; | |
v.srcObject = stream; | |
}) | |
.then(() => new Promise(resolve => v.onloadedmetadata = resolve)) | |
.catch(log); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment