Skip to content

Instantly share code, notes, and snippets.

@gjj
Created October 27, 2019 16:43
Show Gist options
  • Save gjj/2e94bf31a206ea506ff35e1efbae2634 to your computer and use it in GitHub Desktop.
Save gjj/2e94bf31a206ea506ff35e1efbae2634 to your computer and use it in GitHub Desktop.
<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