Reputation: 150
I am testing a webrtc implementation. I currently am able to get access to navigator.mediaDevices.getUserMedia on my desktop computer. However, when I open up my localHost using my computers IP Address on my mobile phone, I get a message saying that navigator.mediaDevices.getUserMedia is undefined.
on my computer I navigate to: http://127.0.0.1:3000/basic-p2p/#8922097 (this works and allows me access to my video stream)
on my mobile phone I navigate to:
http://<my ip address>:3000/basic-p2p/#8922097
(this opens the webapp on my mobile phone, but the navigator object is undefined)
or
http://127.0.0.1:3000/basic-p2p/#8922097
(this doesnt open the webapp on my mobile phone, I just include it to be exhaustive)
the specific error I get is:
Cannot read properties of undefined (reading 'getUserMedia')
I see that it works on http: on my localhost on my computer but it doesnt work when I switch to using my IP Address on either my computer or my phone. please help, How can I give my mobile phone access to navigator.mediaDevices.getUserMedia while still testing in development?
in case it helps, this is specifically the line that blows up when I switch to using my computers IP address to access localhost.
navigator.mediaDevices.getUserMedia({ audio: true, video: false}).then(stream => {
localVideo.current.srcObject = stream
userStream.current = stream
Upvotes: 0
Views: 1669
Reputation: 34
http works only for localhost or 127.0.0.1, For accessing video/camera feeds you will need https.
Looking at the above description, I assume you are using just and html page with video scripts. Question: Are you trying to access desktop camera from mobile.
Upvotes: 1