Rajeev Akotkar
Rajeev Akotkar

Reputation: 1397

WebRTC : navigator.mediaDevices.getUserMedia not working in Chrome on Android

While I am working on basic React example with WebRTC (simple-peer) :

navigator.mediaDevices.getUserMedia({ video: true, audio: true }).then(stream => {
      setStream(stream);
      if (userVideo.current) {
        userVideo.current.srcObject = stream;
      }
    })

I get the error as below :

enter image description here

I see that navigator.mediaDevices.getUserMedia is compatible with Chrome on android so I wonder what causes this issue here. Kindly help on this.

Upvotes: 0

Views: 3011

Answers (2)

copser
copser

Reputation: 2641

Whiltelist your server by opening chrome://flags and search for unsafely-treat-insecure-origin-as-secure:

chrome://flags/#unsafely-treat-insecure-origin-as-secure

and add your server name http://foobar, relaunch chrome.

NOTE

This should be used only for testing!!!

Upvotes: 2

Pradeep
Pradeep

Reputation: 59

I also had the same problem. The mobile browser hasn't asked about permissions. Just try it on Secure Connection (ie: https, SSL).

Upvotes: 2

Related Questions