Can't get user media from Webview on Android

0 favourites
  • 5 posts
From the Asset Store
High quality user interface sound effects for Sci-Fi projects
  • Hello,

    I tried the Camera example and it is working fine in the PC browser.

    It is working fine in Chrome on Android.

    I made a web view using flutter that displays the camera sample (uploaded at a https URL on my server), the page finds and lists the available cameras, but when I click "Get Camera" button, it is always declined.

    My App has the Camera permission On and requires the camera in the manifest.

    Note: The above scenario uses flutter's WebViewScaffold. When I use flutter's WebView, the app crashes whenever I click on the list to pick a camera (the cameras are listed correctly, though)

    Thank you.


  • Soul3 we haven't tried doing any integration with the flutter webview, and your solution sounds somewhat hybrid. The usermedia plugin has specific code in it to request the camera permission at runtime if it detects it was an Android(cordova) export using the cordova permissions plugin. If the plugin is absent, or if your using a different export type it will not request the permissions for you. It's important that the permissions are specified in the AndroidManifest.xml and requested as required at runtime, otherwise you won't be able to access camera input.

    If you are using the microphone with the camera you will also have to request additional permissions.

  • Thank you.

    What we currently have is:

    A Construct3 Game (the camera sample made by Scirra) exported as HTML5 and uploaded on a server.

    It works fine in Browser.

    A Flutter app (with Camera permissions in the manifest) with a web view.

    The game doesn't work in the web view. It doesn't even list the available cameras.

    Is there a way to allow the webview to access the cameras?

    Also, if we can access the camera somehow in flutter without the webview, can we send this camera stream to the game. i.e. if the game can't access the camera from the webview, we will access the camera from outside the webview and send the stream to game?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The easiest way would be for your flutter code to request the camera permission before loading the webview. For Android permissions you need to list the permission in the manifest as well as request it when required.

    Trying to communicate between flutter code and your webview will likely prove hard, and possibly insecure. The Cordova exports we use for Android and iOS have a "bridge" to allow passing data and instructions between Java and JS code. You would likely have to implement this yourself for flutter...

  • Thank you :) I will give it a try.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)