cocos2d-x i9100 音效过多闪退问题不完美解决方案

来源:互联网 发布:腾讯股票数据接口api 编辑:程序博客网 时间:2024/04/29 15:42
cocos2dx/cocos2d-x-2.1.5/CocosDenshion/android/opensl/SimpleAudioEngineOpenSL.cpp


unsigned int SimpleAudioEngineOpenSL::playEffect(const char* pszFilePath, bool bLoop)
{
    unsigned int soundID = s_pOpenSL->preloadEffect(pszFilePath);


    if (soundID != FILE_NOT_FOUND)
    {
        if (s_pOpenSL->getEffectState(soundID) == PLAYSTATE_PLAYING)
        {
            s_pOpenSL->setEffectState(soundID, PLAYSTATE_STOPPED);
            s_pOpenSL->setEffectState(soundID, PLAYSTATE_PLAYING);
            s_pOpenSL->setEffectLooping(soundID, bLoop);
        }
        else
        {
            s_pOpenSL->setEffectState(soundID, PLAYSTATE_STOPPED);
            s_pOpenSL->setEffectState(soundID, PLAYSTATE_PLAYING);
            s_pOpenSL->setEffectLooping(soundID, bLoop);
        }


    }


    return soundID;

}


就是在播放音效时不创建新的音效,而是停止之前的音效再重新播放,播出来会比较怪,但不闪退了

0 0
原创粉丝点击