I have been away from playing with WebRTC for quite awhile, but I am back.
I am trying to code a simple example of using MediaStream API "getUserMedia" but I'll be damned if I can figure out why it's not working!
It's probably something very simple and I'll be kickng myself when you tell me.
Here is the html:
<!DOCTYPE html> <html lang = "en">
<head>
<meta charset = "utf-8" />
</head>
<body>
<video autoplay></video>
<script src = "client.js"></script>
</body>
</html>
And here us the javascript client.js:
function hasUserMedia() { //check if the browser supports the WebRTC
return !!(navigator.mediaDevices.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia);
}
if (hasUserMedia()) {
navigator.mediaDevices.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia;
//enabling video and audio channels
navigator.mediaDevices.getUserMedia({ video: true, audio: true }, function (stream) {
var video = document.querySelector('video');
//inserting our stream to the video tag
video.src = window.URL.createObjectURL(stream);
}, function (err) {});
} else {
alert("WebRTC is not supported");
}
The response I get it: WebRTC is not supported
What am I doing wrong?
Thanks.
Ray