Skip to content

Instantly share code, notes, and snippets.

@vinooniv
Created April 29, 2020 18:00
Show Gist options
  • Save vinooniv/f551249042b45e9b6d192810c3afd9d6 to your computer and use it in GitHub Desktop.
Save vinooniv/f551249042b45e9b6d192810c3afd9d6 to your computer and use it in GitHub Desktop.
WebRTC video stream
<html>
<body>
<video id="video" width="480" height="320" autoplay playsinline></video>
<script>
const videoElement = document.getElementById('video');
navigator.mediaDevices.getUserMedia({ video: true, audio: false })
.then(stream => {
videoElement.srcObject = stream;
videoElement.play();
})
.catch(err => {
alert(`Following error occured: ${err}`);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment