0

I try to make a simple video permission projects with audio and it successfully took permission but after provide the permission it's show an error as video is null. Bellow the code using JS,

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Media Capture</title>
</head>
<body>
    
    <script>
       let constraints = {'video': true, 'audio': true} 

       navigator.mediaDevices.getUserMedia(constraints)
       .then(function(stream){
            let video = document.querySelector('video');
            video.srcObject=stream;
            video.play();
            console.log(stream)
       })
       .catch(function(err){
           console.log(err)
       })
    </script>
</body>
</html>

The error is given in attached file:

on Google Chrome browser showed the bellow error,

enter image description here

on Firefox browser showed the bellow error,

enter image description here

Note: please concern on above JS code and browser error and please help me to solve it. Advanced thanks!

Imdadul Haque
  • 1,635
  • 5
  • 23
  • 44

0 Answers0