Reputation: 106
I have simple ViewController with WKWebView configured as follows:
webView.configuration.allowsInlineMediaPlayback = true
webView.configuration.mediaTypesRequiringUserActionForPlayback = .video
But right after loading a web page with YouTube video it starts to play automatically (and switching to full screen at the same time) without any user interaction which is required. How to disable autoplay?
Upvotes: 8
Views: 5675
Reputation: 386
I also had same problem, YouTube video was playing in full screen.
webview.configuration.allowsInlineMediaPlayback = true
Programmatically setting allowsInlineMediaPlayback
value didn't work for me.
You can avoid video switching fullscreen by enable inline playback for WKWebview.
Upvotes: 8
Reputation: 6532
Check the webView storyboard property Interaction for Audio Playback
. Yes, I know, this is a question about video, but setting the Video Playback checkbox doesn't work, at least not on a target iOS 13 simulator!
Probably just check everything in that section - inline playback, interaction for Audio, interaction for Video. That's what I'm doing, although my test shows only Audio is necessary. I suspect this is a WKWebView bug and Apple will fix it so that Video properly works instead of Audio :-)
Upvotes: 0