I have 2 audio files that I want to play at different times: background.wav a sneeze.wav. I believe that I have to convert both wav files into mp3, caf and ogg files. Then I do this:

static const int FILE_COUNT = 2;
std::string _audioBackgroundFiles[FILE_COUNT];
_audioBackgroundFiles[0] = "background.mp3";
    _audioBackgroundFiles[1] = "background.caf";
    _audioBackgroundFiles[1] = "background.ogg";

for(int index = 0; index < FILE_COUNT; ++index){
        auto id = AudioEngine::play2d(_files[index], false, 1.0f, &_audioProfile);

I don't understand how to create an audio profile? Do you create a profile for every sound? I'm very confused.

  • \$\begingroup\$ similar issue here with v3.10, I didn't bother to search for a solution because AudioEngine is still in it's experimental phase \$\endgroup\$ – rraallvv Feb 29 '16 at 2:33

This is what I ended up doing:

#include "audio/include/AudioEngine.h"

using namespace cocos2d::experimental;


_musicVol = 5;
_backgroundAudioProfile = AudioEngine::INVAILD_AUDIO_ID;

if (_backgroundAudioProfile == AudioEngine::INVAILD_AUDIO_ID) {
    _backgroundAudioProfile = AudioEngine::play2d("background.mp3", true, _musicVol);

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.