77

我有一个使用WkWebView从 Soundcloud 播放音频的应用程序,在 iOS 13 Beta 6 上,当应用程序不在前台时音频停止,即使AudioBackground Modes中打开也是如此。

开始播放时会抛出此断言:

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 中不会发生,在该版本中,音频在后台正常播放。

4

1 回答 1

2

我猜你正在使用电容器。

我遇到了和你一样的问题,看起来关于“不存在后台任务”的最后一个错误与 Capacitor 的BackgroundTask插件有关,无论你是否使用它(BackgroundTask.swift

很明显,iOS 12 和 iOS 13 之间发生了一些变化,但到目前为止还没有弄清楚如何定义背景音频所需的权利。

编辑:它只发生在使用 HTML5 音频时。

于 2019-10-06T13:58:37.563 回答