Raspberry Pi Internet Radio Player

Tutorial: Raspberry Internet streaming radio

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.

Raspberry Pi Radio

Step 1:

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!

Step 2:

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!

Step 3:

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


Step 4:

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/


Step 5:

I have made the source code and icons I used available here.


I am not yet using github for my projects but hopefully will be soon!


Step 6:

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


Controls

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.





blog comments powered by Disqus