Skip to content Skip to sidebar Skip to footer

Webrtc. Not Showing Video

I decided to study WebRTC, but not showing video. Help please. What am I doing wrong? Using Chrome My code:

Solution 1:

Working code:

<head><metacharset="UTF-8"></script></head><body><script>window.onload = function () {
            var constraints = { audio: true, video: { width: 1280, height: 720 } }; 

navigator.mediaDevices.getUserMedia(constraints)
.then(function(mediaStream) {
  var video = document.querySelector('video');
  video.srcObject = mediaStream;
  video.onloadedmetadata = function(e) {
    video.play();
  };
})
.catch(function(err) { console.log(err.name + ": " + err.message); });
        };
    </script><videoid="video"autoplay="autoplay"width="400"></video></body></html>

Post a Comment for "Webrtc. Not Showing Video"