为何audioengine 3.15 版 播放循环音乐时间长后切后台还在播,若是切前台回来后立刻再切到后台他就不播了。
没客服大哥回复下吗
看下你AppDelegate.cpp的代码
// 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();
//SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
LuaEngine::getInstance()->executeGlobalFunction("applicationDidEnterBackground");
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
Director::getInstance()->startAnimation();
//SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
LuaEngine::getInstance()->executeGlobalFunction("applicationWillEnterForeground");
#if defined(ANDROID)
auto scheduler = Director::getInstance()->getScheduler();
if (scheduler)
{
scheduler->performFunctionInCocosThread(=mutable {
LuaEngine::getInstance()->executeGlobalFunction(“appWillEnterForegroundActiveAlbum”);
});
}
else
{
CCLOG(“not found scheduler.”);
}
#endif
}
你lua中的applicationDidEnterBackground写了什么
// 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();
//不管用的是哪个pause都没用
#if USE_AUDIO_ENGINE
AudioEngine::pauseAll();
#elif USE_SIMPLE_AUDIO_ENGINE
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
SimpleAudioEngine::getInstance()->pauseAllEffects();
#endif
LuaEngine::getInstance()->executeGlobalFunction(“applicationDidEnterBackground”);\通知lua层,可忽略
}
lua没有调用音频,只是处理协议东西。可忽略
你播放音乐用的哪个声音引擎