MAUI WebView RTC Video stream on Android

79 Views Asked by At

Hello I'm trying to stream video from my Android phone Camera to the MAUI WebView

That is the approach: I have JavaScript application where when button is clicked I'm asking for camera permission and starting a stream to the video element in HTML.

I'm loading this application in WebView with source and when I click the button to connect, nothing happens. My camera is not showed in the WebView. I'm seeing only this image:

I have these enabled in AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

In the output console I'm seeing this line:

[CameraManagerGlobal] Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client

This is how I grant access to the camera when asked from JavaScript

 internal class CustomWebChromeClient : MauiWebChromeClient
    {
        public CustomWebChromeClient(IWebViewHandler handler) : base(handler)
        {

        }

        public override void OnPermissionRequest(PermissionRequest request)
        {
            try
            {
                request.Grant(request.GetResources());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
    }

This is the result: no video showed in the WebView enter image description here

0

There are 0 best solutions below