The only problem i'm having is that i'm unable to disable playing videos on full screen according to apple documentation this is enabled by default and needs to be set as follows:
webView.configuration.allowsInlineMediaPlayback = true
Which is based on my understanding how it's supposed to be. However this doesn't work and even after configuration right after you press play on video it opens up in native full screen player. I'm using WKWebView.
Apple's Documentation for this
I faced with this problem using video tag in web view. I have three videos in the page, and all videos successively played full screen. I solved this problem by
1.Check Inline Playback
2.Add playsinline attribute to video tag
<video src="your_videosrc" autoplay playsinline></video>
Glad someones help :)
Playing a video inline requires two prerequisites:
The configuration of the WKWebView has needs to be set while initialising. Modifying allowsInlineMediaPlayback
at a later point will not work:
let configuration = WKWebViewConfiguration()
configuration.allowsInlineMediaPlayback = true
let webView = WKWebView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height), configuration: configuration)
view.addSubview(webView)
In order for the web view to know that the video should start playing inline the appropriate URL parameter needs to be set.
For this you simply have to append ?playsinline=1
.
Example:
webView.load(URLRequest(url: URL(string: "https://www.youtube.com/watch?v=OYbXaqQ3uuo?playsinline=1")!))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With