# Raspberry Pi radio player with touchscreen

## 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.

![](https://cdn-learn.adafruit.com/assets/assets/000/019/199/medium800/projects_Raspberry_Pi_Radio.jpg?1409130217)

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!

## 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

Danger: 

# Raspberry Pi radio player with touchscreen

## Preparing the Raspberry Pi

![](https://cdn-learn.adafruit.com/assets/assets/000/019/204/medium800/projects_raspberry_pi_1601_LRG.jpg?1409157269)

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](../../../../adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi)

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](../../../../adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/touchscreen-install-and-calibrate#manual-calibration)

![](https://cdn-learn.adafruit.com/assets/assets/000/019/203/medium800/projects_raspberry_pi_tstest.png?1409157261)

Info: 

# Raspberry Pi radio player with touchscreen

## Installing the Music Player Daemon

By this stage you will now have a Raspberry Pi with a touch screen display. &nbsp;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](../../../../adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/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 **m** usic **p** layer **c** lient 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&amp;e=1365390433&amp;h=a0fef58c2149248d6bff1f7b7b438931
mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_intl_lc_radio2_p?s=1365376067&amp;e=1365390467&amp;h=d43dc8ae0f888809462a6cb7c389b46b
mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_intl_lc_radio3_p?s=1365376123&amp;e=1365390523&amp;h=d53cf2a92272f3289b314a2251d23bc8
mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_intl_lc_radio4_p?s=1365376126&amp;e=1365390526&amp;h=ed9a0642b30c422b07fbcd8683c52335
mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_intl_lc_5live_p?s=1365376271&amp;e=1365390671&amp;h=e0d82133f35ae74d41d5eab6b9c150a6
```

You can now check that **mpc** is working by starting a radiostation. &nbsp;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&nbsp; **/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

# Raspberry Pi radio player with touchscreen

## Installing Radioplayer

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

[Download the Python code and icons](https://learn.adafruit.com/system/assets/assets/000/019/200/original/Pi_Radio_player.zip)
Download the Python code and icons from the link above. &nbsp;Extract the files onto a memory stick and copy into a folder onto the Raspberry Pi.&nbsp; (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**

Info: 

At this stage everything should be ready to go!

Test it out by running:

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

# Raspberry Pi radio player with touchscreen

## About Radioplayer

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

![](https://cdn-learn.adafruit.com/assets/assets/000/019/201/medium800/projects_Raspberry_Pi_Radio.jpg?1409135922)

 **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.


## Featured Products

### Adafruit PiTFT - 320x240 2.8" TFT+Touchscreen for Raspberry Pi

[Adafruit PiTFT - 320x240 2.8" TFT+Touchscreen for Raspberry Pi](https://www.adafruit.com/product/1601)
Is this not the cutest little display for the Raspberry Pi? It features a 2.8" display with 320x240 16-bit color pixels and a resistive touch overlay. The plate uses the high speed SPI interface on the Pi and can use the mini display as a console, X window port, displaying images or video...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1601)
[Related Guides to the Product](https://learn.adafruit.com/products/1601/guides)
### Enclosure for PiTFT - Raspberry Pi Model B

[Enclosure for PiTFT - Raspberry Pi Model B](https://www.adafruit.com/product/1892)
Need a way to protect your Pi while your adorable PiTFT is still connected?&nbsp;Adafruit on the case! Sorry about the pun but we're really excited about this injection molded design and when we get excited we make puns. &nbsp;This case is perfect for accommodating both the standard <a...></a...>

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1892)
[Related Guides to the Product](https://learn.adafruit.com/products/1892/guides)
### Raspberry Pi Model B 512MB RAM

[Raspberry Pi Model B 512MB RAM](https://www.adafruit.com/product/998)
Adafruit ships the **Raspberry Pi Model B 512MB RAM** as of 10/18/2012.  
  
The Raspberry Pi® is a single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of stimulating the teaching of basic computer science in schools. The Raspberry...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/998)
[Related Guides to the Product](https://learn.adafruit.com/products/998/guides)
### USB Powered Speakers

[USB Powered Speakers](https://www.adafruit.com/product/1363)
Add some extra boom to your audio project with these powered loudspeakers. We sampled half a dozen different models to find ones with a good frequency response, so you'll get quality audio output for music playback. Simply connect the standard 3.5mm stereo plug into your Raspberry Pi model...

In Stock
[Buy Now](https://www.adafruit.com/product/1363)
[Related Guides to the Product](https://learn.adafruit.com/products/1363/guides)

## Related Guides

- [PiPhone - A Raspberry Pi based Cellphone](https://learn.adafruit.com/piphone-a-raspberry-pi-based-cellphone.md)
- [RasPipe: A Raspberry Pi Pipeline Viewer, Part 2](https://learn.adafruit.com/raspipe-a-raspberry-pi-pipeline-viewer-part-2.md)
- [RasPipe: A Raspberry Pi Pipeline Viewer, Part 1](https://learn.adafruit.com/raspipe-a-raspberry-pi-pipeline-viewer.md)
- [Raspberry Pi Pygame UI basics](https://learn.adafruit.com/raspberry-pi-pygame-ui-basics.md)
- [Touchscreen Pi Timelapse Controller](https://learn.adafruit.com/touchscreen-pi-timelapse-controller.md)
- [DIY WiFi Raspberry Pi Touchscreen Camera](https://learn.adafruit.com/diy-wifi-raspberry-pi-touch-cam.md)
- [apt.adafruit.com](https://learn.adafruit.com/apt-adafruit-com.md)
- [RasPi - Animated GIF Picture Frame](https://learn.adafruit.com/raspi-animated-gif-picture-frame.md)
- [Mini Mac Pi](https://learn.adafruit.com/mini-mac-pi.md)
- [Processing on the Raspberry Pi & PiTFT](https://learn.adafruit.com/processing-on-the-raspberry-pi-and-pitft.md)
- [Kali Linux on the Raspberry Pi with the PiTFT](https://learn.adafruit.com/kali-linux-on-the-raspberry-pi-with-the-pitft.md)
- [Adafruit PiTFT - 2.8" Touchscreen Display for Raspberry Pi](https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi.md)
- [Ultimate Youtube Live Camera](https://learn.adafruit.com/ultimate-youtube-live-camera.md)
- [Using the Slamtec RPLIDAR on a Raspberry Pi](https://learn.adafruit.com/slamtec-rplidar-on-pi.md)
- [PiGRRL - Raspberry Pi Gameboy](https://learn.adafruit.com/pigrrl-raspberry-pi-gameboy.md)
