#pragma once
#include "global.h"
class MusicPlayer
{
public:
	MusicPlayer();
	virtual ~MusicPlayer();
	void Init();
	float GetMusicVolume();//取当前播放器音量
	void SetMusicVolume(float vol);//设置当前播放器音量
	void StopMusic();//停止播放音乐
	void FadeOutMusic(float fadeOutSecond);
	void ChangeMusic(std::wstring musicName, float fadeInSecond = 0);
	void ResumeMusic(float fadeInSecond = 0);
	bool IsPlaying();
	const wchar_t* GetLastPlayMusic();
private:
	Mix_Music* GetMusic(std::wstring musicName);
	Mix_Music* GetMusicLoop(std::wstring musicName);//尝试取music的loop部分
	float musicVolume = 1;//音乐音量
	std::unordered_map<std::wstring, Mix_Music*> loadedMusic;//已载入的音乐
	std::wstring currentMusic;
	bool currentMusic_inLoop = false;
	std::wstring RMU_Music;
	bool RMU_Music_inLoop = false;
	bool setFadeOut = false;
	double RMU_Pos = 0;
	friend void MusicFinished();
};

