how to call getUserMedia() in Flutter Inappwebview library?

45 views Asked by At

I'm using flutter_inappwebview version: 5.5.0+5. Currently, I want to load https://webrtc.github.io/samples/src/content/getusermedia/gum/ with flutter_inappwebview on Android. When the user clicks the Open camera button, InAppWebview will display a popup request permission in InAppWebview like other browsers (e.g. Google Chrome).

chrome_browser

In this document, getUserMedia() is required, but I don't know how to use it where.

This is my code.

InAppWebView(
    initialUrlRequest: "https://webrtc.github.io/samples/src/content/getusermedia/gum/",
     initialOptions: InAppWebViewGroupOptions(
      crossPlatform: InAppWebViewOptions(
        mediaPlaybackRequiresUserGesture: false,
      ),
      android: AndroidInAppWebViewOptions(
        useHybridComposition: true
      ),
      ios: IOSInAppWebViewOptions(
        allowsInlineMediaPlayback: true,
      )
    ),
)

When The user clicks "Open camera" button, An exception is thrown:

D/CameraExtImplXiaoMi(21761): initCameraDevice: 1
E/cr_VideoCapture(21761): allocate: manager.openCamera: 
E/cr_VideoCapture(21761): java.lang.SecurityException: validateClientPermissionsLocked:1253: Caller "com.example.demo.stag.debug" (PID 11056, UID 21761) cannot open camera "1" without camera permission
E/cr_VideoCapture(21761):   at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:1268)
E/cr_VideoCapture(21761):   at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(CameraManager.java:715)
E/cr_VideoCapture(21761):   at android.hardware.camera2.CameraManager.openCameraForUid(CameraManager.java:961)
E/cr_VideoCapture(21761):   at android.hardware.camera2.CameraManager.openCameraForUid(CameraManager.java:982)
E/cr_VideoCapture(21761):   at android.hardware.camera2.CameraManager.openCamera(CameraManager.java:820)
E/cr_VideoCapture(21761):   at WV.EW.startCaptureMaybeAsync(chromium-TrichromeWebViewGoogle6432.aab-stable-609923033:60)
E/cr_VideoCapture(21761): Caused by: android.os.ServiceSpecificException: validateClientPermissionsLocked:1253: Caller "com.example.demo.stag.debug" (PID 11056, UID 21761) cannot open camera "1" without camera permission (code 1)
E/cr_VideoCapture(21761):   at android.os.Parcel.createExceptionOrNull(Parcel.java:2440)
E/cr_VideoCapture(21761):   at android.os.Parcel.createException(Parcel.java:2410)
E/cr_VideoCapture(21761):   at android.os.Parcel.readException(Parcel.java:2393)
E/cr_VideoCapture(21761):   at android.os.Parcel.readException(Parcel.java:2335)
E/cr_VideoCapture(21761):   at android.hardware.ICameraService$Stub$Proxy.connectDevice(ICameraService.java:669)
E/cr_VideoCapture(21761):   at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(CameraManager.java:691)
E/cr_VideoCapture(21761):   ... 4 more

how to call getUserMedia() in Flutter Inappwebview library?

0

There are 0 answers