我的代码
char MusicLoc [50][200];
char Music [50][50];
int MusicBox(int IndexMusic)
{
std::string rawloc = ((std::string)"open \""+MusicLoc[IndexMusic]+Music[IndexMusic]+"\"type mpegvideo alias "+Music[IndexMusic]);`
mciSendString(rawloc.c_str(), NULL, 0, 0);
mciSendString(((std::string)"play "+Music[IndexMusic]).c_str(), NULL, 0, 0);
return 0;
}MusicLoc包含路径,音乐包含文件名,所以MusicLoc1+Music1应该是C:\etc\audio.mp3,一开始它工作得很好,但后来它随机停止工作,我尝试了所有方法,但它不工作,所以我猜使用mciSendString是不推荐的,那么有谁知道一个好的和轻量级的音频库?
编辑:第一个mciSendString返回266,第二个返回275,如果它有任何用处的话,但我真的没有找到关于它们的好文档。
此外,GetLastError说没有错误...
发布于 2012-10-03 00:07:50
如果没有错误,则mciSendString的返回值应为零。你的问题表明你得到了错误!
要很好地解码错误,请使用mciGetErrorString
类似这样的东西(摘自我的代码,所以你必须调整变量名,等等)
wchar_t cmd[250];
swprintf(cmd,249,L"open %s alias an1",fname1.c_str());
err = mciSendString(cmd, 0, 0, 0 );
if( err ) throw err;
...
catch ( unsigned int& err ) {
wprintf(L"Playing %s %s %s\n",fname1.c_str(),fname2.c_str(),fname3.c_str());
wchar_t msg[128];
mciGetErrorString( err, msg,128 );
wprintf(L"%s\n",msg);https://stackoverflow.com/questions/12690169
复制相似问题