Basic HTML5 Video
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
<video id="vid" autoplay /> |
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
// get the video element | |
const vid = document.getElementById("vid"); | |
// request the video stream | |
navigator.mediaDevices.getUserMedia({ | |
video: true | |
}).then((stream) => { | |
// pass stream to video element | |
vid.srcObject = stream; | |
}).catch(ex => { | |
console.error(ex.message); | |
}); |
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
video { | |
border: 1px solid black; | |
height: 300px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment