Raspberry Pi Internet Radio Player
eskMate2000">Updated blog post: Home-automation with a touchscreen Pi
Latest video: Introducing the Hudl2 - budget Android tablet from Tesco
This project is based around the 2.8” touch screen from adafruit.
The full details of building and setting up the touch screen can be found on the adafruit website here. This must be done before trying to use the radio!
This project creates an internet streaming radio for the Raspberry Pi using the 2.8” touchscreen. This does not use the x interface and makes use of Pygame.
Set up the Adafruit TFT using the instructions provided by Adafruit. Make sure that all the steps are followed for calibration of the touch screen. There is no other control of the radio player other than the touch screen so if this is not done it won’t work!
Plug in a speaker or headphones into your audio jack. It took me nearly 5 minutes to work out my I was getting no sound when I hadn’t switched on my speakers!
If your Raspberry Pi is up to date you should already have the libraries for Pygame installed.
sudo apt-get update
sudo apt-get upgrade
Install mpc and mpd and add some radio stations to your play list
sudo apt-get install mpd mpc
mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_intl_lc_radio1_p?s=1365376033&e=1365390433&h=a0fef58c2149248d6bff1f7b7b438931
mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_intl_lc_radio2_p?s=1365376067&e=1365390467&h=d43dc8ae0f888809462a6cb7c389b46b
mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_intl_lc_radio3_p?s=1365376123&e=1365390523&h=d53cf2a92272f3289b314a2251d23bc8
mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_intl_lc_radio4_p?s=1365376126&e=1365390526&h=ed9a0642b30c422b07fbcd8683c52335
mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_intl_lc_5live_p?s=1365376271&e=1365390671&h=e0d82133f35ae74d41d5eab6b9c150a6
mpc and internet radio stations are very well documented so I won’t go into too much detail here. The stations listed above are for BBC Radio stations in the UK.
If you want to save, edit and open your play list they are saved in /var/lib/mpd/playlists/
I am not yet using github for my projects but hopefully will be soon!
Save the python program radioplayer.py and all the icons into one folder. You should run the python program from within that folder.
sudo python radioplayer.py
Play mpc play
Pause mpc stop
Refresh mpc stop followed by mpc play
Volume up mpc volume +10
Volume down mpc volume -10
Mute mpc volume 0
Previous station mpc prev
Next station mpc next
Each control is started with a command such as subprocess.call(“mpc play”, shell=True)
The code still contains much debugging and developer information so you will see lots of additional comments in the console - sorry!
Have fun, let me know what you think.
Now you are ready to add more channels to you mpc player check out this tutorial.