Skip to content

Instantly share code, notes, and snippets.

@tomowarkar
Created December 16, 2019 09:10
Show Gist options
  • Save tomowarkar/6e6d38a494ff41b176ae027691e9a85b to your computer and use it in GitHub Desktop.
Save tomowarkar/6e6d38a494ff41b176ae027691e9a85b to your computer and use it in GitHub Desktop.
ブラウザでのビデオ表示
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0" />
<title></title>
<style>
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
</style>
</head>
<body>
<video id="video" width="720" height="560" autoplay muted></video>
</body>
<script>
const video = document.getElementById('video')
const startVideo = () => {
navigator.getUserMedia(
{ video: {} },
stream => video.srcObject = stream,
err => console.error(err)
)
}
startVideo()
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment