对于 web 视图中的 html 音频元素,iOS 13 webaudio 完全损坏

fro*_*975 8 audio ios cordova web-audio-api ios13

我正在使用cordova和wkwebview构建一个手机游戏,我遇到了一个重大问题,音频无法在iOS 13(特别是iPadOS 13.2.2)上运行。我有几个 html 音频元素连接到一个 AudioContext,当我在上下文恢复后播放一个时,没有 js 错误,从 js 端看一切都很好。但是,它不播放任何声音,并且在本机 iOS 端,它会引发此错误:

2019-11-15 18:27:09.610800-0500 MyApp[9045:99562] [assertion] Error acquiring assertion: <NSError: 0x2811ddfe0; domain: RBSAssertionErrorDomain; code: 2; reason: "Client is missing required entitlement"> {
    userInfo = {
        RBSAssertionAttribute = <RBSLegacyAttribute: 0x111048cf0; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>;
    }
}
2019-11-15 18:27:09.610840-0500 MyApp[9045:99562] [ProcessSuspension]  0x108ee7138 - ProcessAssertion() PID 9045 Unable to acquire assertion for process with PID 9045
2019-11-15 18:27:09.610894-0500 MyApp[9045:99269] [ProcessSuspension] 0x108ee7138 - ProcessAssertion::processAssertionWasInvalidated()
Run Code Online (Sandbox Code Playgroud)

我尝试在 xcode 的背景模式选项卡中添加“音频、AirPlay 和画中画”和“背景处理”标志,但它们没有效果。其他注意事项:它在模拟器中播放音频,即使它仍然抛出错误,但无法在实际设备上播放。此外,音频确实可以使用 AudioBuffer 正确播放,只是受到影响的音频元素。不幸的是,我无法将 AudioBuffers 用于我的配乐,因为它们仅设计用于短声音,并且加载全长歌曲需要很长时间。

我已将此作为 webkit 错误提交:https ://bugs.webkit.org/show_bug.cgi ? id = 204261

有没有人能够在 iOS 13 上使用 html 音频,或者知道任何解决方法?

小智 5

同样的问题,在后台使用 WKWebView 和音频在 30 秒后停止。在 X-Code 的背景模式选项卡中勾选“音频、AirPlay 和画中画”和“背景处理”标志无效。在 iOS 12 中一切正常,我不明白这是新 iOS 13 系统或新 Apple 公司政策的问题。在他们关于 IOS 13 和背景音频的文档中没有指定或更改任何内容(https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_editing/creating_a_basic_video_player_ios_and_tvos/enabling_background_audio)。在我通过 Apple Developer Support 提出的问题中,我仍然没有回答。...如果有人可以回答我们这个问题或帮助我们。先感谢您。