如何在C ++中播放歌曲 [英] How Do I Play Songs In C++
本文介绍了如何在C ++中播放歌曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用c ++播放歌曲。我尝试使用winmm lib,它工作正常。我现在的目标是通过创建某种歌曲播放列表并将它们存储在一个阵列中来播放多首歌曲。我试了但是playound功能一直让我看错。任何人都可以告诉我如何做到这一点?
**我得到的错误与playound函数中的文字有关,显示
** LsongList未定义**
I was trying to play songs in c++. I tried using the winmm lib and it worked fine. My goal now is to play multiple songs by creating some sort of song playlist and storing them in an array. I tried it but the playsound function keeps showing me errors. Can anyone advise me how i can do that?
**The error that i get is related to the text in the playsound function which shows
**LsongList is undefined**
#include <iostream>
#include <fstream>
#include <string>
#include <Windows.h>
#include <mmsystem.h>
using namespace std;
int main()
{
string songlist[3];
songlist[0] = "a.wav";
songlist[1] = "b.wav";
songlist[2] = "c.wav";
for(int i =0; i<3; i++)
{
PlaySound(TEXT(songlist[i]), NULL, SND_ASYNC | SND_NODEFAULT );
}
system("pause");
}
推荐答案
我没有发言人来测试它现在,但它编译并运行没有错误。
I don't have speakers to test it now, but it compiles and runs without errors.
void run()
{
LPCWSTR songlist[3] =
{
TEXT("C:\\sounds\\APPLAUSE.wav"),
TEXT("C:\\sounds\\ARROW.wav"),
TEXT("C:\\sounds\\BOMB.wav")
};
for(int i =0; i<3; i++)
{
PlaySound(songlist[i], NULL, SND_ASYNC | SND_NODEFAULT );
}
}
int _tmain(int argc, _TCHAR* argv[])
{
run();
system("pause");
return 0;
}
这篇关于如何在C ++中播放歌曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文