如何禁用 iOS Webview 在视频播放时全屏显示

发布于 2025-01-13 20:48:36 字数 222 浏览 2 评论 0原文

我正在尝试播放嵌入 iOS 本机应用程序中的内嵌视频。

无论我做什么,播放视频后播放器都会自动进入全屏。

我正在尝试所有提到的建议,例如 playsinlineallowfullscreen="false"controls="false" 等。

有没有办法防止iOS webview 无法进入全屏?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

单调的奢华 2025-01-20 20:48:36

Swift 5.5

你只需要 allowsInlineMediaPlayback = true

class WebViewConfigurator {

    private var _webViewConfig = WKWebViewConfiguration()

    var webKitConfig : WKWebViewConfiguration {
        _webViewConfig
    }

    init() {
        _webViewConfig.allowsInlineMediaPlayback = true
    }
}

Swift 5.5

You just need allowsInlineMediaPlayback = true

class WebViewConfigurator {

    private var _webViewConfig = WKWebViewConfiguration()

    var webKitConfig : WKWebViewConfiguration {
        _webViewConfig
    }

    init() {
        _webViewConfig.allowsInlineMediaPlayback = true
    }
}
鹿港巷口少年归 2025-01-20 20:48:36

您可以通过代码中的配置,使用 WKWebViewConfiguration 和 allowedInlineMediaPlayback 在 iOS Web 视图中启用内联播放:

将此属性设置为 true 以内联播放视频,或设置为 false 以使用本机全屏控制器。在 iPhone 上将视频元素添加到 HTML 文档时,还必须包含playsinline 属性。
该属性的默认值对于 iPhone 为 false,对于 iPad 为 true。

您可以在此答案中查看示例:https://stackoverflow.com/a/59834721/334402

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文