Hi, background music stops after some background/foreground (using AudioEngine)
I use Cocos2d-x 3.17 with the latest patch on gitHub (cocos/audio/apple)
It happens on iOS.
Usually, after a foreground, music plays 1 seconds then in AudioEngineImpl::update
I see that sourceState is AL_STOPPED and Music stops (maybe this is the effect and not the cause)
When this happens, I log AudioEngine::_audioIDInfoMap[audioID].state
and the AudioState is 1 (PLAYING)
I have a simple code, only I start music in loop in the init of MainPage:
int idBackGroundMusic = AudioEngine::play2d(maintheme.mp3);
AudioEngine::setLoop(idBackGroundMusic, true);
AudioEngine::setVolume(idBackGroundMusic, 0.5f);
return true;
and pause and resume in AppDelegate
// This function will be called when the app is inactive. Note, when receiving a phone call it is invoked.
void AppDelegate::applicationDidEnterBackground()
{
Director::getInstance()->stopAnimation();
AudioEngine::pauseAll();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
Director::getInstance()->startAnimation();
AudioEngine::resumeAll();
}
Try with different maintheme.mp3
Could you help me?
Thank you