WebRtc in Xamarin WebView on iOS, black camera image

jemunk 96 Reputation points
2021-01-08T14:04:18.753+00:00

With iOS 14.3 we finally have WebRTC available in WkWebView. Several sites can confirm this. But I can't make it work in our app based on Xamarin Forms using WkWebView. When it shows the video of the camera it is all just black. No errors showing up. Before the black screen, it asked for permission to access mic and cam.
I have tried with our own video conference solution based on TokBox. I have also tried using the simple WebRTC test site https://appr.tc/

I also see it working in Firefox app, as Firefox is also just a WkWebView. So I can confirm it works on my phone.
First I thought it was a permission issue. But both Mic and Video permission are activated in the Settings for the app.

Does anyone know how to make it work?

Developer technologies | .NET | Xamarin
{count} votes

Accepted answer
  1. jemunk 96 Reputation points
    2021-01-11T09:20:14.527+00:00

    I found the solution. It is a matter allowing inline media playback. Is solved by this custom renderer in the iOS project:

    public class CustomWebViewRenderer : WkWebViewRenderer
    {
    public CustomWebViewRenderer() : base(new WKWebViewConfiguration() {
    AllowsInlineMediaPlayback = true, // Enables view of video in video conference, or else user just sees a black image.
    })
    {
    }
    }

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Jørgen Storlie 1 Reputation point
    2021-01-21T11:02:39.237+00:00
    0 comments No comments

  2. Amr Kamal 1 Reputation point
    2022-05-21T23:20:03.927+00:00

    @jemunk
    I've the same problem and I implemented the sample using java script but

    AllowsInlineMediaPlayback = true

    not working

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.