gpt4 book ai didi

iOS 13 在后台关闭应用程序 : Audio Stream Issue

转载 作者:行者123 更新时间:2023-12-04 14:03:24 24 4
gpt4 key购买 nike

我被困在使用 Swift 5 和 Xcode 11 在后台播放音频。

启用后台模式和启动 AVAudioSession 不再起作用,并且当您离开应用程序时,应用程序会在几秒钟后关闭。

首先,我得到了一个权利升温,但是流开始了:

Error acquiring assertion: <NSError: 0x2829830f0; domain: RBSAssertionErrorDomain; code: 2; reason: "Required client entitlement is missing"> {
userInfo = {
RBSAssertionAttribute = <RBSLegacyAttribute: 0x1050a9040; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>;
}

在后台几秒钟后它会关闭:
[ProcessSuspension] Background task expired while holding WebKit ProcessAssertion (isMainThread? 1).

如果我保持应用程序打开,音频仍然会停止:
[ProcessSuspension] 0x10dfc8848 - ProcessAssertion::processAssertionWasInvalidated()

苹果每年都喜欢改变这一点。到目前为止,任何人都可以在 iOS 13 和 Xcode 11/Swift 5 上使用它吗?

谢谢!

更新 : 我刚发现 此问题仅影响通过 WebView 播放的音频 .我不确定这是否是 iOS 13 上的错误,或者 Apple 是否真的从多任务处理中删除了 WebView。所以我改变了我的应用程序,现在正在通过 AVPlayer 播放音频。背景音频再次起作用。

最佳答案

你把恢复播放音频的代码放在你的 Appdelegate 中了吗

func applicationDidEnterBackground(_ application: UIApplication) {


do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.mixWithOthers, .allowAirPlay])
try AVAudioSession.sharedInstance().setActive(true)
} catch {
print(error)
}

}

此外,从您的目标功能上制作音频、airplay 和画中画

关于iOS 13 在后台关闭应用程序 : Audio Stream Issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58090326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com