In script.js I tried to access a webcam. Yesterday it was working fine but now it isn't and i have also allowed permission by site settings.
script.js
const videoGrid = document.getElementById('video-grid');
const myVideo = document.createElement('video');
myVideo.muted = true;
let myVideoStream;
navigator.mediaDevices.getUserMedia({
video:true,
audio:true
}).then(stream => {
myVideoStream = stream;
addVideoStream(myVideo,stream);
})
const addVideoStream = (video,stream) => {
video.srcObject = stream;
video.addEventListener('loadedmetadata',() => {
video.play();
})
videoGrid.append(video)
}
room.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Zoom Clone</title>
<link rel="stylesheet" href="style.css">
<script defer src="script.js"></script>
</head>
<body>
<div id="video-grid"></div>
</body>
</html>