I have this code for a webcam application that has error which is :overload resolution failed.
const video=document.getElementById('webcam');
const canvas=document.getElementById('photo');
const ctx=canvas.getContext('2d');
function getVideo() {
navigator.mediaDevices.getUserMedia({audio:false, video:true}).then(localMediaStream=>{
video.srcObject=window.URL.createObjectURL(localMediaStream);
video.play();
});}
function paint() {
const width=video.videoWidth;
const height= video.videoHeight;
canvas.width=width;
canvas.height=height;
setInterval(function (){ctx.drawImage(video,0,0,width,height)},16);
}
video.addEventListener('canplay',paint());
getVideo();