【问题标题】:How to keep my audio app active in background when interruptions occurs?发生中断时如何让我的音频应用程序在后台保持活动状态?
【发布时间】:2011-11-15 14:55:50
【问题描述】:

我正在尝试使用 AVAudioSession 和 AVAudioPlayer 以及音频背景模式来使我的应用程序在后台保持活动状态。 如果没有中断,它工作正常。 但, 当我收到 audioPlayerBeginInterruption 消息时,我启动了一个 backgroundTask 并等待 audioPlayerEndInterruption 消息,然后重新启动我的音频会话。

(我注意到在 audioPlayerBeginInterruption 应用程序仍处于活动状态后,播放器只是暂停,但在 audioPlayerEndInterruption 应用程序暂停后)

问题 1:如果 audioPlayerEndInterruption 消息在 10 分钟后到达,后台任务被终止,应用程序被挂起,我无法重新启动我的音频会话

问题 2:对于多个应用/游戏,我收到了 audioPlayerBeginInterruption 消息,但我从未收到 audioPlayerEndInterruption。

如何让我的应用程序始终处于活动状态?

感谢您的所有回答和建议

【问题讨论】:

    标签: iphone audio background avaudiosession interruption


    【解决方案1】:

    如果中断持续超过十分钟,您将无法在后台恢复音频。

    如果前台应用请求独占音频会话,也没有办法强制您的后台音频会话处于活动状态。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      • 2017-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多