MiniEngine/SDLWrapper/Music.h

53 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
#include "include.h"
2017-06-18 20:37:45 +08:00
#include <memory>
#include <string>
#include "ErrorViewer.h"
#include "Audio.h"
2017-06-23 13:17:55 +08:00
#include "__Noncopyable.h"
2017-07-01 17:11:06 +08:00
#include "__Plugin.h"
#include "begin_code.h"
/// Forward Declaration
class Music
{
public:
2017-06-23 13:17:55 +08:00
Music()=default;
Music(const std::string& Filename);
bool isReady() const;
void release();
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
friend class MusicPlayer;
2017-07-01 17:11:06 +08:00
friend class _internal::Plugin;
};
2017-06-23 13:17:55 +08:00
class MusicPlayer : public AudioPlayer, public NonCopyable
{
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.
int play(Music music, int loops);
void pause();
void resume();
void rewind();
2017-06-23 13:17:55 +08:00
int setPosition(double second);
int stop();
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;
private:
Music m;
};
#include "end_code.h"