Using cocos2d-x, on iphone sounds stop working after interrupt

I am using fmod in my game on cocos2d-x. On iphone (haven’t tested yet on Android), whenever the app receive an interrupt (phone call, start imusic from bottom menu, etc, the sound is not working anymore when coming back. However, if I close the app normally, and resume it, it starts working again.

I do have mixerSuspend and mixerResume setup in my applicationDidEnterBackground and applicationWillEnterForeground. So it seems this works when closing app normally and resuming it normally, but the resume does not work when coming back from an interrupt.

Any idea?

Thanks

Can you confirm that the functions (applicationDidEnterBackground and applicationWillEnterForeground) are being triggered, and that the mixer calls are being made to FMOD?

Just verified different scenarios.

When leaving the app normally (press home button or something), the applicationDidEnterBackground is called and within it I call sound_System->mixerSuspend();. All work fine.
When coming back in the app, the applicationWillEnterForeground is called and I call sound_System->mixerResume(); Everything is fine.

When in the game, if I swipe up the bottom of the screen (to open the quick access panel) and start music, nothing is called. The sounds stop within the game. If I stop the apple imusic again, nothing is called and the sounds in the game are not coming back. However, if I put the game in background and come back, the applicationWillEnterForeground is called and the sounds are coming back.

Same thing as above happens when receiving a phone call. After the phone call, sounds within the game are stopped and no calls were made to applicationWillEnterForeground or even applicationDidEnterBackground. When I put app in background and resume again, all sounds are back.

I’ve read here: (https://www.fmod.com/resources/documentation-api?version=2.0&page=platforms-ios.html#ios-specific-starter-guide) in the “handling interruption” that I might need to handle them myself since audio interrupt is not the same as background interrupt it seems. However, it would mean modifying the core of cocos2d-x. I don’t think this is a good idea. Also, in the example, you call a simple " gSystem->mixerResume()". In cocos2d-x, we do not have this global variable gSystem and I have no clue how I would access my sound system variable that is within my personal code in C++ to bring it to the objective C of the core of cocos2d-x.

So this is where I am stuck right now.

Thanks for helping.

You could possibly get around the audio stopping by using a different AudioCategory, although the issue sounds to be in cocos2d if it doesn’t have any other callback that you can use.