anon
anon

Reputation:

How to make an audioID with the cocos experimental audio engine

When using the simple audio engine, you make an audio ID like so:

#include "SimpleAudioEngine.h"
using namespace CocosDenshion;

auto audio = SimpleAudioEngine::getInstance();

I want to do the same but with the experimental audio engine, and globally, in the header I tried:

#pragma once
#include "AudioEngine.h"

audio = AudioEngine::getDefaultProfile();

But it didn't work. How do you make an audio id with the experimental engine?

Upvotes: 0

Views: 1422

Answers (1)

Komal Shah
Komal Shah

Reputation: 11

Yes, you can get audio ID in AudioEngine

static int play2d(const std::string& filePath, bool loop = false, float volume   = 1.0f, const AudioProfile *profile = nullptr);


int volumeID;
volumeID = AudioEngine::play2d("bgVolume.mp3",true, 1.0);

When the profile is not specified, the default profile will be used and here in volumeID you will get the ID for that particular audio.

Upvotes: 1

Related Questions