Hice una funcion para tomar una foto con la camara del pc pero no me muestra nada alguien sabe que pasa
window.addEventListener('load', init);
functionconst init()captureVideoButton {=
var video = document.querySelector('#v''#screenshot .capture-button'),;
const canvasscreenshotButton = document.querySelector('#c''#screenshot-button'),;
const btnimg = document.querySelector('#t''#screenshot img'),;
const imgvideo = document.querySelector('#img''#screenshot video');
const navigator.getUserMediacanvas = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUSerMedia || navigatordocument.msGetUserMediacreateElement('canvas');
if (navigator.getUserMedia) {
navigatorcaptureVideoButton.getUserMedia({
video: true
onclick },= function(stream) {
video.src = windownavigator.URLmediaDevices.createObjectURLgetUserMedia(streamconstraints);
video.play();
}, functionthen(ehandleSuccess) {
console.logcatch(ehandleError);
});
screenshotButton.onclick = video.addEventListener('loadedmetadata',onclick = function() {
canvas.width = video.videoWidth,videoWidth;
canvas.height = video.videoHeight;
}, false);
btn.addEventListener('click', function() {
canvas.getContext('2d').drawImage(video, 0, 0);
// Other browsers will varfall imgDataback =to canvas.toDataURL('imageimage/png');png
img.src = imgcanvas.setAttributetoDataURL('src', imgData'image/webp');
});
}function elsehandleSuccess(stream) {
screenshotButton.disabled = alert("Actualizafalse;
tu nvegador");
video.srcObject = }
stream;
}
<img src="" id="img">
<video id="v"><autoplay></video>
<canvas<img id="c"></canvas>src="">
<button id ="t">Toma una<canvas Foto<style="display:none;"></button>canvas>