User avatar
debazthed
Posts: 5
Joined: Thu Jan 19, 2012 1:34 pm

Play an MP3 from a C++ program

Thu Jan 31, 2013 8:44 pm

Hello everyone,

I am looking for a way to play an mp3 file from a c++ program.

The only thing I found is mpg123's api, which I could not make much sense of. Does it even play files or is it just a decoder?

Any suggestions?

Kind Regards
deBazthed

dextrus
Posts: 119
Joined: Tue Jan 24, 2012 10:10 pm
Location: Eastleigh, Hampshire
Contact: Website

Re: Play an MP3 from a C++ program

Thu Jan 31, 2013 9:08 pm

This isn't really a Pi question. I typed in "C++ mp3 playback" into Google and got endless answers. You can do it.

/Dextrus
Have more FUN with your Pi. Visit www.pi-fun.com

bbond007
Posts: 73
Joined: Sun Nov 04, 2012 6:10 pm

Re: Play an MP3 from a C++ program

Fri Feb 01, 2013 12:26 am

debazthed wrote:Hello everyone,

I am looking for a way to play an mp3 file from a c++ program.

The only thing I found is mpg123's api, which I could not make much sense of. Does it even play files or is it just a decoder?

Any suggestions?

Kind Regards
deBazthed
http://stackoverflow.com/questions/4288 ... files-in-c

you may also want to look at "hello_video" with a little work maybe you could modify it to work with mp3. i dunno if the hardware decodes mp3(in hardware)

Lint
Posts: 12
Joined: Fri Feb 01, 2013 3:19 pm

Re: Play an MP3 from a C++ program

Fri Feb 01, 2013 3:42 pm

I would recommend you to try and play an Ogg Vorbis files instead.

Besides being a free format and having a better quality-to-bitrate ratio, it's really easy to do so if you follow the examples online, and it looks like more platform-friendly than FMOD. (Although I've never used fmod.)

mikie
Posts: 7
Joined: Sun Oct 09, 2011 3:36 am

Re: Play an MP3 from a C++ program

Tue Feb 05, 2013 4:59 pm

Hi,

This is an excellent little C program which plays MP3 music files from the command line (no X gui)...

http://hzqtc.github.com/2012/05/play-mp ... libao.html

I also tried his Play URL version which also worked a treat...I just found a local radio station broadcasting in MP3 format (not BBC unfortunately) and hey presto! - turned my Pi into a digital internet radio :)

Don't forget to install the libmpg123 and libao libraries first before trying to compile it...

sudo apt-get install libmpg123-dev
sudo apt-get install libao-dev

Hope this helps,

mikie

Return to “C/C++”