我有一个使用 AVPlayer 播放音频的应用程序。我通过将音频类别设置为启用背景音频AVAudioSessionCategoryPlayback
并将所需的UIBackgroundModes
设置添加到audio
info.plist 中。
在 iOS 5 上,当您按下主页按钮时,应用程序会进入后台,并且音频仍会播放一段时间,但是当我双击主页按钮时,整个设备会锁定 10 秒左右,并且音频最终会停止。
但是,该应用程序仍在运行,因为我可以启动它并查看应用程序的状态。不幸的是,音频系统似乎很糟糕,因为任何后续操作通常都会导致崩溃。
当音频停止时,我在设备的控制台中看到以下内容:
Jun 26 12:39:28 unknown SpringBoard[15] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Jun 26 12:39:53 unknown mediaserverd[25406] <Error>: <<<< FIGSERVER >>>> FigPlayerRemoteServer_KillAndForceCrashReport: RPCTimeout message received to terminate [25406] with reason 'fig rpc timeout -- FigSharedRemote_VolumeCategoryForAudioCategory'
Jun 26 12:39:53 unknown ReportCrash[25468] <Notice>: Saved crashreport to /Library/Logs/CrashReporter/mediaserverd-2012-06-26-123953.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
Jun 26 12:39:53 unknown mediaserverd[25406] <Error>: <<<< FIGSERVER >>>> FigPlayerRemoteServer_KillAndForceCrashReport: RPCTimeout message received; stackshot generated
Jun 26 12:39:53 unknown mediaserverd[25406] <Error>: <<<< FIGSERVER >>>> FigPlayerRemoteServer_KillAndForceCrashReport: TERMINATING our process [25406]
Jun 26 12:39:53 unknown com.apple.launchd[1] <Notice>: (com.apple.mediaserverd) Exited: Killed: 9
Jun 26 12:39:54 unknown com.apple.mediaserverd[25469] <Notice>: 2012-06-26 12:39:54.083477 PM [AirTunes] HAL plugin started
Jun 26 12:39:54 unknown kernel[0] <Debug>: launchd[25469] Builtin profile: mediaserverd (sandbox)
Jun 26 12:39:54 unknown mediaserverd[25469] <Error>: 12:39:54.317795 com.apple.AVConference: /SourceCache/GameKitServices/GameKitServices-344.21/AVConference.subproj/Sources/AVConferenceServer.m:1867: AVConferenceServerStart
这似乎只影响 iOS 5。