Overview

Make your very own touchscreen-controller Pi Radio Player! With an ever increasing number of internet radio stations available this project combines the versatility of the Raspberry Pi and the PiTFT 2.8" touchscreen TFTdisplay. A custom display interface lets you control volume, station, and see what's currently playing.

This project is a good one for people who have a little bit of Raspberry Pi experience since there's quite a few steps, but its worth it!

Temporarily unable to load embedded content. Please try again later.

Project steps

  1. Build the PiTFT 320x240 2.8" touchscreen display (this may not be necessary if your PiTFT is pre-assembled)

  2. Calibrate the touchscreen display

  3. Install Music Player Daemon (MPD) and Music Player Client (MPC) on the Raspberry Pi

  4. Find and add internet radio stations to mpc

  5. Download radioplayer source code

  6. Enjoy streaming internet radio on your desk
All the setup and calibration steps for the PiTFT display must be completed.

Preparing the Raspberry Pi

If your Adafruit PiTFT 2.8" Touchscreen display came as a kit you will need to complete the instructions to assemble the screen. Check out the PiTFT Tutorial for more details

Download & burn the PiTFT image or use an existing Raspbian setup and install the easy-setup script. Basically, get the PiTFT setup working first!

If you want to calibrate the screen, check out the detailed calibration steps here

I found that for the most effective use of the touchscreen it was necessary to carry out the manual calibration of the touchscreen.

Installing the Music Player Daemon

By this stage you will now have a Raspberry Pi with a touch screen display.  If you used the Easy Install Image you should now have access to the console via the touch screen display.

Additional instructions on using the console

At this stage it is worth checking that your Raspberry Pi is up to date before continuing.

sudo apt-get update

Now we can install mpc and mpd - the music player client and 'daemon' background controller - and add some radio stations to your play list.

The example stations listed below are BBC channels from the UK, but look around for your own favorite types of music!

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

You can now check that mpc is working by starting a radiostation.  Don't forget to plug in your headphones!

mpc play

A note on playlists

A copy of your playlist can be saved with the command

mpc save my_playlist

The playlist is saved in /var/lib/mpd/playlists/

The playlist can be hand-edited with

sudo nano /var/lib/mpd/playlists/my_playlist

Once edited the playlist can be loaded back into mpc with

mpc load /var/lib/mpd/playlists/my_playlist

I have a number of playlists saved in /var/lib/mpd/playlists with different genres depending on my mood

Installing Radioplayer

The Radioplayer front end software has been written in Python using Pygame and is specific for the TFT 320x240 2.8" screen.  However, it is relatively simple to adapt the code to work in a window.

Download the Python code and icons from the link above.  Extract the files onto a memory stick and copy into a folder onto the Raspberry Pi.  (Or you can place it in the SD card directory on your home computer, the files will be in /boot when the SD card is booted on the Pi)

I save mine into a folder called pi-radio

Ensure that all the icons and python code is saved into the folder /home/pi/pi-radio

At this stage everything should be ready to go!

Test it out by running:

cd /home/pi/pi-radio
sudo python radioplayer.py

About Radioplayer

The interface has been deliberatly kept simple so that it can be operated with your fingers rather than a stylus.

Play - starts mpc on the current playlist

Pause - stops mpc on the current playlist

Volume down - reduces volume

Volume up - increases volume

Mute - volume set to zero

Refresh - stops player, starts player again and refreshes the screen.

Exit - closes radioplayer interface but keeps mpc playing

Station Info

The station information is extracted from the output of

mpc status

Many stations use a common format of

Station name : Track name/information

The Station name is displayed on the first line of the display.

The Track name is displayed on the second line of the display.

If there is no track name a message of "No additional Info" is displayed.