2
\$\begingroup\$

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";
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
    _audioBackgroundFiles[1] = "background.caf";
#else
    _audioBackgroundFiles[1] = "background.ogg";
#endif

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.

\$\endgroup\$
1
  • \$\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\$ Commented Feb 29, 2016 at 2:33

1 Answer 1

1
\$\begingroup\$

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);
}

AudioEngine::pause(_backgroundAudioProfile);
\$\endgroup\$
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.