问题描述
我希望能让玩家在玩游戏时听他们的iPod / iPhone音乐。我使用以下功能启用:
- (void)applicationWillResignActive:(UIApplication *)application
{
[[CCDirector sharedDirector] pause];
[[CDAudioManager sharedManager] setResignBehavior:kAMRBStopPlay autoHandle:YES];
}
暂停背景音乐并允许播放声音效果。到目前为止工作完美。
但问题是,当用户走出游戏,停止iPod / iPhone音乐,并返回游戏背景音乐不简历。任何人都可以帮助我这个。我想要在iPod / iPhone音乐关闭时恢复音乐。
我使用SimpleAudioEngine播放背景音乐。
我使用CDAudioManager播放音效。
感谢
您很可能需要实施
- (void)applicationDidBecomeActive:(UIApplication *)application
[[CDAudioManager sharedManager] resumeBackgroundMusic];
或
playBackground音乐
原因是当你设置音乐在后台播放时,它是一个sharedManager,用户直接去iPod接口,然后按停止。
I want to be able to allow players to listen to their iPod/iPhone music while playing the game.
I use use the following to enable that:
-(void)applicationWillResignActive:(UIApplication *)application { [[CCDirector sharedDirector] pause]; [[CDAudioManager sharedManager] setResignBehavior:kAMRBStopPlay autoHandle:YES]; }
This pauses the background music and allows the sound effects to play. So far works perfectly.
But the problem is, when the user goes out of the game, stops the iPod/iPhone music and returns to the game the background music does not resume. Can anyone help me with this. I want the music to be able to resume when the iPod/iPhone music is turned off.
I use SimpleAudioEngine to play the background music.I use CDAudioManager to play sound effects.
Thanks
解决方案You will most likely need to implement
- (void)applicationDidBecomeActive:(UIApplication *)application
with a
[[CDAudioManager sharedManager] resumeBackgroundMusic];
or
playBackgroundMusic
The reason is that while you did set the music to play in the background, it is a sharedManager, and the user is directly going to the iPod interface and pressing stop.
这篇关于当玩家在关闭iPhone / iPod音乐后返回游戏时,游戏音乐不会恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!