AbhinavVinay
AbhinavVinay

Reputation: 303

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

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

Upvotes: 1

Views: 531

Answers (1)

trumpetlicks
trumpetlicks

Reputation: 7075

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.

Upvotes: 1

Related Questions