C++/sound
Expert: Zlatko - 10/15/2010
Questionhello sir,,,can u pls tell hw to play a wave/mp3 file in c++.
i am using turbo c++ ver 3.0.
AnswerTo play a wav file you can use the windows multimedia API function
PlaySound
Here is a sample
#include <Windows.h>
int main(void)
{
PlaySound("c:\\Windows\\Media\\chimes.wav", NULL, SND_FILENAME);
}
You will need to link in the Winmm.lib library. I don't know how this will fit in with Turbo C++. That is a very old compiler and may not be compatible with newer libraries, and I cannot give you help with it. All I know is that the above program worked for me, but I compiled with visual studio 2010. You can get a free visual studio C++ express edition from
http://www.microsoft.com/express/Downloads/#2010-Visual-CPP
I don't know how to play mp3 files. Sorry, that is the best I can do.
Best regards
Zlatko