GetUserMedia () is not supported in chrome

I am trying to access my webcam using getUserMedia () using my own website, which starts using my own ip address.

It worked fine until I tried my site again. I tried another demo site and the indicated error was received using getUserMedia.

Chrome Version v47.0.2526.80m 32bits

enter image description here

I can access the webcam if I log in to localhost instead of my ipadress. It also works in firefox.

+7
google-chrome webcam
source share
2 answers

Chrome requires Secure Origin (HTTPS) for getUserMedia.

Starting with Chrome 47, getUserMedia () requests are only allowed from a secure source: HTTPS or localhost.

https://developers.google.com/web/updates/2015/10/chrome-47-webrtc?hl=en

+8
source share

Chrome finally implemented the new navigator.mediaDevices.getUserMedia() method, but they added security that would prevent calls from an insecure address (not https or non local servers)

You will name it as follows:

 var video = document.querySelector('video'); navigator.mediaDevices.getUserMedia({video:true}).then(function(mediaStream){ window.stream = mediaStream; video.src = URL.createObjectURL(mediaStream); video.play(); }); 

Or you can use the official webRTC polyfill library adpater.js .

 var constraints = { video: true, audio: true }; navigator.mediaDevices.getUserMedia(constraints) .then(stream => video.srcObject = stream) .catch(e => console.error(e)); 
+7
source share