您的位置:首页 > 移动开发 > Cocos引擎

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

2014-06-14 14:09 726 查看
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;
}

就是在播放音效时不创建新的音效,而是停止之前的音效再重新播放,播出来会比较怪,但不闪退了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: