音频标签无法在WKWebView中播放

时间:2020-06-04 22:09:19

标签: ios swift audio wkwebview

我正在使用WKWebView上的GCDWebServer从本地存储加载TinCan课程。问题是该课程包含播放mp3文件的音频标签。当然可以加载,但不能播放mp3文件。 此警告也似乎与我无关,因为在加载 当然在联机模式下,会出现此警告,但会播放mp3文件。 该应用程序不应该进入后台。
也会授予所有应用程序传输安全设置。
当尝试通过点击播放按钮播放mp3时,此错误会在控制台中出现:

TypeError: null is not an object (evaluating 'this.el.querySelector('[tabindex="0"]').focus')
TypeError: undefined is not an object (evaluating 'this.currTimeline.progress')

ProcessAssertion() PID 92223 Unable to acquire assertion for process with PID 92223
ProcessAssertion::processAssertionWasInvalidated()
reason: "Client is missing required entitlement"> {
    userInfo = {
        RBSAssertionAttribute = <RBSLegacyAttribute: 0x7fd906017b60; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>;
    }
}

这是我为webview设置配置的方式:

        config.userContentController = userContentController
        config.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
        config.preferences.javaScriptEnabled = true
        config.allowsInlineMediaPlayback = true
        config.mediaTypesRequiringUserActionForPlayback = []

        config.allowsAirPlayForMediaPlayback = true
        config.allowsPictureInPictureMediaPlayback = true

它在iOS 13.5上运行,感谢您的帮助。

0 个答案:

没有答案