【问题标题】:WKWebView html5 embedded video plays on simulator but not on real deviceWKWebView html5 嵌入视频在模拟器上播放,但不在真实设备上
【发布时间】:2017-09-20 13:30:04
【问题描述】:

我正在使用包含 WKWebView 来加载 html5 文件的应用程序。其中一些文件包含 .mp4 视频,应在触摸播放按钮上进行复制。

在模拟器中视频播放没有问题,但在真实设备中只能听到声音,而图像只有在按下暂停按钮时才能看到。

我用来加载嵌入视频的 index.html 文件的代码是:

let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let htmlTmp = documentsUrl.appendingPathComponent("data/index.html")
webview.loadFileURL(htmlTmp, allowingReadAccessTo: documentsUrl.appendingPathComponent("data/"))

任何可能的解决方案?

谢谢。

【问题讨论】:

    标签: video xcode8 ios10 wkwebview simulator


    【解决方案1】:

    您需要在 WKWebView 的配置中允许内联媒体播放。

    见:https://developer.apple.com/documentation/webkit/wkwebviewconfiguration

    【讨论】:

    • 我试过这个但没有用。经过大量的谷歌搜索,这似乎是在 iOS 10.2 上开始发生的事情。
    猜你喜欢
    • 2013-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 2011-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多