2017-06-18 17:36:13 +08:00
|
|
|
#pragma once
|
|
|
|
#include "include.h"
|
2017-06-18 20:37:45 +08:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include "ErrorViewer.h"
|
2017-06-23 11:24:50 +08:00
|
|
|
#include "Audio.h"
|
2017-07-04 22:38:33 +08:00
|
|
|
#include "RWOP.h"
|
|
|
|
#include "_MusicType.h"
|
2017-06-23 13:17:55 +08:00
|
|
|
#include "__Noncopyable.h"
|
2017-07-01 17:11:06 +08:00
|
|
|
#include "__Plugin.h"
|
2017-07-31 00:18:10 +08:00
|
|
|
namespace MiniEngine
|
|
|
|
{
|
2017-06-18 17:36:13 +08:00
|
|
|
/// Forward Declaration
|
|
|
|
class Music
|
|
|
|
{
|
|
|
|
public:
|
2017-06-23 13:17:55 +08:00
|
|
|
Music()=default;
|
|
|
|
Music(const std::string& Filename);
|
2017-07-04 22:38:33 +08:00
|
|
|
Music(const RWOP& rwop,MusicType musicType);
|
2017-06-23 13:17:55 +08:00
|
|
|
bool isReady() const;
|
|
|
|
void release();
|
2017-07-04 22:38:33 +08:00
|
|
|
MusicType getType() const;
|
2017-06-18 17:36:13 +08:00
|
|
|
private:
|
|
|
|
std::shared_ptr<Mix_Music> _music;
|
|
|
|
void _set(Mix_Music*);
|
|
|
|
void _clear();
|
2017-06-23 13:17:55 +08:00
|
|
|
Mix_Music* _get() const;
|
2017-07-01 17:11:06 +08:00
|
|
|
|
2017-06-18 17:36:13 +08:00
|
|
|
friend class MusicPlayer;
|
2017-07-01 17:11:06 +08:00
|
|
|
friend class _internal::Plugin;
|
2017-06-18 17:36:13 +08:00
|
|
|
};
|
|
|
|
|
2017-06-23 13:17:55 +08:00
|
|
|
class MusicPlayer : public AudioPlayer, public NonCopyable
|
2017-06-18 17:36:13 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static int GetDecoderNum();
|
|
|
|
static std::string GetDecoderName(int index);
|
|
|
|
|
2017-06-23 13:17:55 +08:00
|
|
|
/// Play Music. Loop: -1:Infinite, >0:Exact that time.
|
2017-06-18 17:36:13 +08:00
|
|
|
int play(Music music, int loops);
|
|
|
|
void pause();
|
|
|
|
void resume();
|
|
|
|
void rewind();
|
2017-06-23 13:17:55 +08:00
|
|
|
int setPosition(double second);
|
2017-06-18 17:36:13 +08:00
|
|
|
int stop();
|
2017-07-04 22:48:44 +08:00
|
|
|
int fadeIn(Music music,int loops,int ms);
|
2017-06-18 17:36:13 +08:00
|
|
|
int fadeIn(int loops, int ms);
|
|
|
|
int fadeOut(int ms);
|
|
|
|
|
2017-06-23 13:17:55 +08:00
|
|
|
bool isPlaying() const;
|
|
|
|
bool isPaused() const;
|
|
|
|
int isFading() const;
|
2017-06-18 17:36:13 +08:00
|
|
|
private:
|
|
|
|
Music m;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-07-31 00:18:10 +08:00
|
|
|
} /// End of namespace MiniEngine
|
|
|
|
|