Studio Wavs
![]() |
No items matching your keywords were found.
How do I get an MP3 file to play in a C++ Console application?
What libraries would I need and how would I do it? I want it to play an MP3 file in the file as the .exe.
PlaySound() is for .wavs unfortunately
I don't want to use SDL and I am using Visual Studio 2010 if that helps any.
I mean I want to play an MP3 with a certain name that is in the same folder that the .exe is in, in case that's not clear. I re-read it and realized it could be taken wrong
So like in a folder named "Console", I want it to have the "console.exe" and the "mysound.mp3" and I want "console.exe" to be able to play "mysound.mp3"
01#include
02#include
03#include
04
05int main()
06{
07 char* WAV = "c:cow.wav";// cow.wav is a piano song in hard drive
08 sndPlaySound(WAV, SND_ASYNC);
09 system("PAUSE");//gives it time to play and not close out
10 return 0;
11}
I used VC++ so "Winmm.lib" was added in linker as additional dependency. Pressed F5 then it compiled and played the music while the command line displayed "Press any key to continue . . ."
Maybe try something like this?
view source
print?
1sndPlaySound((LPCSTR)WAV, SND_ASYNC);
Casting it that way also worked for me.
