#ifndef __NewAudioEngineDemo__NewAudioEngineDemo__
#define __NewAudioEngineDemo__NewAudioEngineDemo__
#include "cocos2d.h"
#include "ui/CocosGUI.h"
#include "VisibleRect.h"
#include "audio/include/AudioEngine.h"
USING_NS_CC;
using namespace ui;
class NewAudioEngineDemo : public Scene
{
public:
CREATE_FUNC(NewAudioEngineDemo);
virtual bool init();
};
class BaseTest : public Layer
{
public:
CREATE_FUNC(BaseTest);
virtual bool init();
virtual std::string title() const;//主标题
virtual std::string subtitle() const;//副标题
virtual void onExit() override;
virtual void restartCallback(Ref* sender);//重新执行当前test
virtual void nextCallback(Ref* sender);//下一个test
virtual void backCallback(Ref* sender);//上一个test
void menuCloseCallback(cocos2d::Ref* pSender);//关闭菜单回调函数
};
class AudioControlTest : public BaseTest
{
public:
CREATE_FUNC(AudioControlTest);
virtual ~AudioControlTest();
virtual bool init();
virtual void update(float dt);
virtual std::string subtitle() const override;
private:
int _audioID;
bool _loopEnabled;
float _volume;
float _duration;
float _timeRatio;
void* _playItem;
void* _timeSlider;
bool _updateTimeSlider;
};
class PlaySimultaneouslyTest : public BaseTest
{
public:
CREATE_FUNC(PlaySimultaneouslyTest);
virtual ~PlaySimultaneouslyTest();
virtual bool init();
virtual std::string subtitle() const override;
private:
static const int TEST_COUNT = 10;
std::string _files[TEST_COUNT];
void* _playItem;
int _playingcount;
};
class AudioProfileTest : public BaseTest
{
public:
CREATE_FUNC(AudioProfileTest);
virtual bool init();
virtual ~AudioProfileTest();
virtual std::string subtitle() const override;
virtual void update(float dt);
private:
static const int FILE_COUNT = 2;
std::string _files[FILE_COUNT];
cocos2d::experimental::AudioProfile _audioProfile;
int _audioCount;
Label* _showLabel;
float _time;
float _minDelay;
void* _timeSlider;
};
class InvalidAudioFileTest : public BaseTest
{
public:
CREATE_FUNC(InvalidAudioFileTest);
virtual bool init();
virtual ~InvalidAudioFileTest();
virtual std::string subtitle() const override;
};
class LargeAudioFileTest : public BaseTest
{
public:
CREATE_FUNC(LargeAudioFileTest);
virtual bool init();
virtual ~LargeAudioFileTest();
virtual std::string subtitle() const override;
};
#endif /* defined(__NewAudioEngineDemo__NewAudioEngineDemo__) */