C++ BASS 实例

#include <iostream>
#include <string>
#include <map>
#include "..\sdk\bass\include\bass.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;
}

 

posted @ 2019-11-02 08:36  YZFHKMS-X  阅读(965)  评论(0编辑  收藏  举报