Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2011-04-22
11
Medium Priority
?
1,040 Views
Last Modified: 2012-06-21
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.

Thanks
0
Comment
Question by:New_Alex
11 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 35450295
The easiest solution would probably be to
ShellExecute(NULL,"open","c:\\path\\file.mp3",NULL,NULL,SW_HIDE);

Open in new window

0
 
LVL 7

Expert Comment

by:lucky_james
ID: 35452031
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\"");
0
 
LVL 1

Author Comment

by:New_Alex
ID: 35452108
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?
Thanks
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 8

Accepted Solution

by:
lomo74 earned 2000 total points
ID: 35452581
http://sourceforge.net/projects/mad/

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.
0
 
LVL 8

Expert Comment

by:lomo74
ID: 35452590
> ... that I can use in a commercial program ...

oooops, missed that. libmad is GPL'ed...
0
 
LVL 8

Expert Comment

by:lomo74
ID: 35452887
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 --
0
 
LVL 1

Author Comment

by:New_Alex
ID: 35453669
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...

Bye
Happy Eastern,

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

0
 
LVL 1

Author Closing Comment

by:New_Alex
ID: 35453673
Full points Deserved for this wonderful answer......
I was looking for this long before....
0
 
LVL 1

Author Comment

by:New_Alex
ID: 35454015
One more question if you don't mind. Is it possible to build this in Visual Studio C++ 2010?
0
 
LVL 1

Author Comment

by:New_Alex
ID: 35455226
Hi Lomo. Can you tell me the steps you ve taken to manage to compile MadPlay in this thread?
http://www.experts-exchange.com/Programming/Languages/CPP/Q_26973930.html
I will give you other full points if you do so...

Thanks
 
0
 
LVL 8

Expert Comment

by:lomo74
ID: 35456206
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:
http://zlib.net/zlib-1.2.5.tar.gz
http://sourceforge.net/projects/mad/files/libmad/0.15.1b/libmad-0.15.1b.tar.gz/download
http://sourceforge.net/projects/mad/files/libid3tag/0.15.1b/libid3tag-0.15.1b.tar.gz/download
http://sourceforge.net/projects/mad/files/madplay/0.15.2b/madplay-0.15.2b.tar.gz/download

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
  C:\work\mad\libid3tag-0.15.1b
  C:\work\mad\libmad-0.15.1b
  C:\work\mad\madplay-0.15.2b
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 -
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question