#include <iostream> #include <string> #include <map> #include "..sdkassincludeass.h" #pragma comment(lib,"..\sdk\bass\lib\bass.lib") typedef std::map < std::string, HSTREAM > MusicMap; int main() { int Volume = 100; std::string Music_Name = "独家硬货.mp3"; HSTREAM Init = 0;//流句柄 MusicMap Music; BASS_Init(-1,44100,0,0,0); BASS_SetConfig(BASS_CONFIG_GVOL_STREAM,Volume * 100); //新建一个迭带器 MusicMap::iterator _findReturn = Music.find(Music_Name); Init = BASS_StreamCreateFile(FALSE,Music_Name.c_str(),0,0, BASS_SAMPLE_LOOP);//得到流句柄 Music.insert(make_pair(Music_Name,Init));//写进列表中 BASS_ChannelPlay(Init,TRUE);//播放 system("pause"); for (MusicMap::iterator i = Music.begin(); i != Music.end(); i++) { BASS_StreamFree(i->second); } Music.clear(); BASS_Free(); system("pause"); return 0; }