iOS 13 - WkWebView:后台播放音频停止

76
我有一个使用WkWebView从Soundcloud播放音频的应用程序,在iOS 13 Beta 6中,当应用程序不在前台时,音频会停止播放,即使在后台模式中打开了Audio。开始播放时,会引发以下断言:
Error acquiring assertion: <NSError: 0x282cf67c0; domain: RBSAssertionErrorDomain; code: 2; reason: "Required client entitlement is missing"> {
userInfo = {
    RBSAssertionAttribute = <RBSLegacyAttribute: 0x1592432e0; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>;
} 

在进入后台状态后,会抛出以下断言并暂停音频:

Can't end BackgroundTask: no background task exists with identifier 13 (0xd), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug. 
[ProcessSuspension] Background task expired while holding WebKit ProcessAssertion (isMainThread? 1).

iOS 12中不会出现这种情况,即使应用在后台运行时音频也会正常播放。


https://dev59.com/-V0a5IYBdhLWcg3wfIl- - MALIKK HABIB UR REHMAN
这是iOS13 WebKit中的一个错误,在iOS14中已经修复。https://bugs.webkit.org/show_bug.cgi?id=203293 - Kamil.S
1个回答

3
我猜你正在使用 Capacitor。
我遇到了和你一样的问题,看起来关于“不存在后台任务”的最后一个错误与 Capacitor 的 BackgroundTask 插件有关,无论你是否在使用它 (BackgroundTask.swift)。
很明显,在 iOS 12 和 iOS 13 之间有些东西发生了变化,但到目前为止,还没有想出如何定义所需的后台音频授权。
编辑:只有在使用 HTML5 音频时才会出现此问题。

12
有人找到解决方案了吗? - bablack

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接