AllowsInlineMediaPlayback Not working

Hi,

Anyone know why below code cannot prevent video automatically play on full screen? The WKWebView showing API content and the content has video advertising which always shown up in full screen mode I am trying to force it to play in line.

webView.configuration.allowsInlineMediaPlayback = true
webView.load(request)

but the video still automatically play in full screen mode.

Anyone know why the allowaInlineMediaPlayback not working? If you know the solution I would appreciate if you can share it with me. Many thanks!!

Regards,
Kok Sing

Hi Kok Sing,

Try and add some more configuration like this:


 let webConfiguration = WKWebViewConfiguration()
        webConfiguration.allowsInlineMediaPlayback = true
        webConfiguration.mediaTypesRequiringUserActionForPlayback = []

        myPlayer = WKWebView(frame: CGRect(x: 0, y: 0, width: 375, height: 300), configuration: webConfiguration)
        self.view.addSubview(myPlayer)

Let me now if that works for you.
Blessings,
—Mark

Hi Mark,

Thanks. Yes, it works.

Regards,
Kok Sing