Game music does not resume when the player returns to the game after turning off iPhone/iPod music

我们两清 提交于 2020-01-15 14:49:19

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/10906141/game-music-does-not-resume-when-the-player-returns-to-the-game-after-turning-off

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!