2

I have a problem when detecting support for getUserMedia. I am using Android 4.2.2.

The problem is that the android browser acts as if it have support for getUserMedia but when using it, I neither get a call to the success function nor the fail function. Code below:

    function onCameraFail(e){
        alert("Failed getting media");
    }

    if (navigator.webkitGetUserMedia) {
            alert("getMedia supported");
            navigator.webkitGetUserMedia({video:true}, function (stream) {
                alert("Got media");
            }, onCameraFail);
            alert("after getMedia");
    }else{  
        //Old device, no support for providing a photo
        alert("No support for getUserMedia");           
    }

When on Android browser, this code shows the popup "getUserMedia supported" but I never get any popup that says "Got media" or "Failed getting media". When running the same code in Chrome on Android, it says "No support for getUserMedia"

Why this behavior? I thought that this was the common way to check for support of functions.

Mikael Holmgren
  • 2,466
  • 1
  • 18
  • 27

2 Answers2

0

GetUseMedia is not supported in Android Browsers.

http://caniuse.com/stream

getUserMedia(constraints, successCallBack, errorCallBack)

In errorCallBack, check for the error you are getting. You should get the exact reason every time.

Jinto
  • 847
  • 1
  • 11
  • 27
0

WebRTC ability is available on Android. It is dependant on if the application has:

  1. The right user permissions
  2. The user has clicked yes to said permission pop ups
  3. The ChromeWebView was instantiated after the above
  4. The ChromeWebView onPermissionRequest has been overrided to allow camera access

You should get the appropriate error message (when calling getUserMedia) within JavaScript to know where this fails e.g. NotReadableError highlights permissions/inability to start a video source. Always use the Adapter for consistent error messages: https://webrtc.github.io/adapter/adapter-latest.js

Please see the following for more information: NotReadableError: Could not start source

Marcus
  • 1,880
  • 20
  • 27