C++., Simple line to play an MP3 File ("C:/MyFile.MP3)

Any simple programing command to simply play an MP3 file from my HardDrive in C++?

Please note that any depended external components have to be made clear and installed manually in my OS because I am using a bare, streamlined version of Windows XP.

Who is Participating?

provides library to play back mp3 files plus command line player.

with little tweaks (need zlib as well and some modifications here and there), I had madplay up and running in 10 minutes using Win SDK 7.1 + MSVC Express 2008 --
300k exe, monolithic, no external dependencies at all --
it should be trivial to look into madplay code, grab the main routine, link the whole thing into your own exe.
The easiest solution would probably be to

Open in new window

Shellexecute will open your mp3 in the default player program you have configured.
If you want to run your mp3 in a particulay program then you need to try out their SDK.
For example,
For  VLC:
System("c:\\path_to_VLC\\vlc.exe \"c:\\path\\file.mp3\"");

For windows media player:
System("c:\\path_to_wmplayer\\wmplayer.exe \"c:\\path\\file.mp3\"");
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

New_AlexAuthor Commented:
Yes, but I want a method that will not depend on other players or anything I can not sell myself. If you know any media .exe or SDK etc that I can use in a commercial program then ok.

Any Ideas?
> ... that I can use in a commercial program ...

oooops, missed that. libmad is GPL'ed...
Ooops again --
from README file:

  This means MAD can be incorporated into other software as long as that
  software is also distributed under the GPL. (Should this be undesirable,
  alternate arrangements may be possible by contacting Underbit.)

so commercial use is permitted too, as long as you get an agreement with the authors --
New_AlexAuthor Commented:
I love you mate. Best answer ever !!!

Full points are given man.

Take care with my full wished.

I thank all of you here for your response, I love you all...

Happy Eastern,

(Fuck Royal Family, turn your TV OFF during wedding ceremonies. )

New_AlexAuthor Commented:
Full points Deserved for this wonderful answer......
I was looking for this long before....
New_AlexAuthor Commented:
One more question if you don't mind. Is it possible to build this in Visual Studio C++ 2010?
New_AlexAuthor Commented:
Hi Lomo. Can you tell me the steps you ve taken to manage to compile MadPlay in this thread?
I will give you other full points if you do so...

mmmh VS 2010, I don't know...
I did install it some time ago, but suddenly removed it as soon as I realized it wouldn't let me "attach to process" to debug... and since I occasionally write services, I really need this, so I went back to VS 2008.
I suppose that it is possible, though, and steps needed for VS 2008 should be valid for VS 2010 too.
So... instructions follow.

1) download zlib, libmad, libid3tag, madplay from the internet:

2) unpack zlib somewhere, let's say C:\work\zlib-1.2.5
then go under that directory, open file win32\Makefile.msc
change line 25 so it reads
CFLAGS  = -nologo -MT -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC)
instead of
CFLAGS  = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC)
this is to statically link against CRT, thus removing dependencies from MSVCRwhatever.DLL. save, exit.
now, open a SDK command prompt (so you have INCLUDE and LIB environment variables set correctly)
cd C:\work\zlib-1.2.5
type the command:
nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj"
zlib is being built...

3) ok so it's time to build mad...
unpack the three mad projects somewhere, let's say C:\work\mad\...
so now you have
go to C:\work\mad\madplay-0.15.2b\msvc++, open file madplay.dsw with visual studio.
confirm conversion of projects to the new format; it will complain about not finding zlib, ignore the error, we're going to provide our own.
go to visual studio options / projects and solutions / VC++ directories; add C:\work\zlib-1.2.5 under include files and library files.
build libid3tag.
build libmad.
then open properties of madplay project; under linker / input / dependencies add zlib.lib. do this for each configuration (debug, release).
then build madplay. that's all...
I hope I forgot nothing... if you find any problems let me know.
Ciao - Lorenzo -
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.