501 auto ret = AudioEngineTestDemo::init();
504 _files[0] =
"background.mp3";
505#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
506 _files[1] =
"background.caf";
508 _files[1] =
"background.ogg";
511 std::string fontFilePath =
"fonts/arial.ttf";
520 for(
int index = 0; index <
FILE_COUNT; ++index){
521 sprintf(text,
"play %s",
_files[index].c_str());
523 auto playItem = TextButton::create(text, [&](TextButton* button){
524 int index = button->getTag();
526 if(
id != AudioEngine::INVALID_AUDIO_ID){
533 AudioEngine::setFinishCallback(
id, [&](
int id,
const std::string& filePath){
542 playItem->setTag(index);
543 playItem->setPositionNormalized(pos);
544 this->addChild(playItem);
549 Vec2 origin = Director::getInstance()->getVisibleOrigin();
550 Size size = Director::getInstance()->getVisibleSize();
552 auto profileInfoLabel = Label::createWithTTF(
"AudioProfile Info:\n max instance:3 \n minimum delay:1.0", fontFilePath, 12);
553 profileInfoLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
554 profileInfoLabel->setPosition(Vec2(origin.x, origin.y + size.height * 0.65f));
555 addChild(profileInfoLabel);
558 _showLabel = Label::createWithTTF(
"audio count:0", fontFilePath, 12);
559 _showLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
560 _showLabel->setPosition(Vec2(origin.x, origin.y + size.height * 0.5f));
563 auto timeSlider = SliderEx::create();
564 timeSlider->setEnabled(
false);
565 timeSlider->setPositionNormalized(pos);
566 addChild(timeSlider);
std::string _files[FILE_COUNT]
cocos2d::AudioProfile _audioProfile
cocos2d::Label * _showLabel
virtual void update(float dt) override
static const int FILE_COUNT