7

I am trying to play inline video embedded inside iOS native app.

Whatever I do, the player keeps entering full screen automatically once the video is played.

I was trying all mentioned suggestions such as playsinline , allowfullscreen="false", controls="false" etc.

Is there a way to prevent iOS webview from entering full screen?

Yuvals
  • 3,094
  • 5
  • 32
  • 60

2 Answers2

3

You can enable inline playback in an iOS web view via configuration in your code, using WKWebViewConfiguration and allowsInlineMediaPlayback:

Set this property to true to play videos inline, or false to use the native full-screen controller. When adding a video element to an HTML document on iPhone, you must also include the playsinline attribute. The default value of this property is false for iPhone and true for iPad.

You can see an example in this answer: https://stackoverflow.com/a/59834721/334402

Mick
  • 24,231
  • 1
  • 54
  • 120
1

Swift 5.5

You just need allowsInlineMediaPlayback = true

class WebViewConfigurator {

    private var _webViewConfig = WKWebViewConfiguration()

    var webKitConfig : WKWebViewConfiguration {
        _webViewConfig
    }

    init() {
        _webViewConfig.allowsInlineMediaPlayback = true
    }
}
Mamad Farrahi
  • 394
  • 1
  • 5
  • 20