Add decoder query functions in class MusicPlayer and SoundPlayer

This commit is contained in:
Kirigaya Kazuto 2017-06-06 15:50:56 +08:00
parent bf0f6b8b6d
commit 01c31a4f71
2 changed files with 30 additions and 0 deletions

View File

@ -2231,6 +2231,18 @@ namespace MiniEngine
return _music.get(); return _music.get();
} }
//static
int MusicPlayer::GetDecoderNum()
{
return Mix_GetNumMusicDecoders();
}
//static
std::string MusicPlayer::GetDecoderName(int index)
{
return std::string(Mix_GetMusicDecoder(index));
}
Music MusicPlayer::loadMusic(std::string Filename) throw(ErrorViewer) Music MusicPlayer::loadMusic(std::string Filename) throw(ErrorViewer)
{ {
Mix_Music* temp = Mix_LoadMUS(Filename.c_str()); Mix_Music* temp = Mix_LoadMUS(Filename.c_str());
@ -2321,6 +2333,18 @@ namespace MiniEngine
return _sound.get(); return _sound.get();
} }
//static
int SoundPlayer::GetDecoderNum()
{
return Mix_GetNumChunkDecoders();
}
//static
std::string SoundPlayer::GetDecoderName(int index)
{
return std::string(Mix_GetChunkDecoder(index));
}
SoundPlayer::SoundPlayer(int Channels) SoundPlayer::SoundPlayer(int Channels)
{ {
Mix_AllocateChannels(Channels); Mix_AllocateChannels(Channels);

View File

@ -673,6 +673,9 @@ namespace MiniEngine
class MusicPlayer : public AudioPlayer class MusicPlayer : public AudioPlayer
{ {
public: public:
static int GetDecoderNum();
static std::string GetDecoderName(int index);
Music loadMusic(std::string Filename) throw (ErrorViewer); Music loadMusic(std::string Filename) throw (ErrorViewer);
int play(Music music, int loops); int play(Music music, int loops);
@ -709,6 +712,9 @@ namespace MiniEngine
class SoundPlayer : public AudioPlayer class SoundPlayer : public AudioPlayer
{ {
public: public:
static int GetDecoderNum();
static std::string GetDecoderName(int index);
SoundPlayer(int Channels = 16); SoundPlayer(int Channels = 16);
Sound loadSound(std::string Filename) throw (ErrorViewer); Sound loadSound(std::string Filename) throw (ErrorViewer);
ChannelID playSound(Sound sound, int loops) throw (ErrorViewer); ChannelID playSound(Sound sound, int loops) throw (ErrorViewer);