This is all on iOS and I’m using mp3 for my backgorund music. I’m using the SimpleAudioEngine in my game, in a pretty basic way using playEffect and playBackgroundMusic and changing volumes. I’m having an issue with my game being but into the background and then the user starts up a song on iOS with iTunes/Music/whatever if they re-enter my game their iOS music gets paused/stopped any my game music resumes. What’s strange is that if I have iOS music playing before I start my game (fresh launch) the iOS music will continue playing like I want it to.
The issue:- iOS music started while game in background, the iOS music is paused/stopped when game enters foreground
Expected behavior:- iOS music continues to play and my game music should not play.
Strange:- I get the correct behavior when game launches fresh (not from pause). The currently playing iOS music is not paused/stopped when game launches.
I am calling SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); from AppDelegate::applicationDidEnterBackground();
and also calling SimpleAudioEngine::sharedEnegine()->resumeBackgroundMusic(); from AppDelegate::applicationWillEnterForeground();
EDIT: Found a solution for iOS. I had to go change the SimpleAudioEngine initialization to grab the shared CDAudioManager and do this:
[[CDAudioManager sharedManager] setResignBehavior: kAMRBDoNothing autoHandle:YES];