I want to make a program on the Internet that will capture an image through the user's webcam.
I am using getUserMedia web API. Here is my code, but it does not work. How can I change it to capture a webcam image?
<div id="container"> <video autoplay="true" id="videoElement"> </video> </div> <script> </script>
There is JS:
var video = document.querySelector("#videoElement"); navigator.getUserMedia, elem = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; console.log(navigator.getUserMedia); if (navigator.getUserMedia) { navigator.getUserMedia({video: true}, handleVideo, videoError); } function handleVideo(stream) { video.src = window.URL.createObjectURL(stream); } function videoError(e) {
source share