我目前使用AVAudioPlayer而在前台,但是当我preSS home键我的应用程序去的背景和音乐停止播放音乐。我设置的类别为我AVAudioSession到AVAudioSessionCategoryPlayback并设置为活动为YES。此外,我还添加了音频键UIBackgroundModes在我的Info.plist。
I currently use AVAudioPlayer to play music while in the foreground, but when I press the home button my application goes to the background and the music stops. I set the category for my AVAudioSession to AVAudioSessionCategoryPlayback and set active to YES. Additionally, I added the audio key to UIBackgroundModes in my Info.plist.
还有什么我需要做的,使背景音乐播放?
Is there anything else I need to do to enable background music playback?
推荐答案有很明显的在模拟器中的错误 - 它没有在那里工作,而它在设备上工作精细
There's apparently a bug in the simulator - it doesn't work there, while it works fine on the device.
(编辑:由不工作我的意思是,当应用程序进入的背景,但玩家的状态保持玩,似乎让玩的声音停止,但你不能听到它)
( and by "doesn't work" I mean the sound stops when the app enters background, yet the player's status remains "playing" and it seems to keep "playing", although you can't hear it).
更多推荐
如何使用AVAudioPlayer在后台播放音乐,一边?
发布评论