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
-
- Posts: 119
- Joined: Tue Jan 24, 2012 10:10 pm
- Location: Eastleigh, Hampshire
- Contact: Website
Re: Play an MP3 from a C++ program
This isn't really a Pi question. I typed in "C++ mp3 playback" into Google and got endless answers. You can do it.
/Dextrus
/Dextrus
Have more FUN with your Pi. Visit www.pi-fun.com
Re: Play an MP3 from a C++ program
http://stackoverflow.com/questions/4288 ... files-in-cdebazthed 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
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)
Re: Play an MP3 from a C++ program
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.)
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.)
Re: Play an MP3 from a C++ program
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
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
Re: Play an MP3 from a C++ program
Yes it does. Thank you.

I replaced my door-bell (and this old style AC/AC powersupply) with this. The doorbell-switch pulls an I/O-pin over 100kOhm to 3.3V and activates a doorbell-sound.
I will replace this with a optocoupler, because of the long wire to the push button which is at the gate.
(Thunderstorm and electric field => induced voltage)