The Raspberry Pi 2 as an Internet Radio using Mopidy

Recently I got a Raspberry Pi 2, which is said to be 6 times faster than the original Raspberry Pi B. This makes it more suitable for tasks like being a media player.

Getting a full CanaKit Raspberry Pi 2 Ultimate Starter Kit adds many components for experimentation (LEDs, resistors, breadboard, 40-pin ribbon cable, ...etc.). The price was attractive since with Amazon you get free shipping, and therefore it will be cheaper than getting it directly from CanaKit.

Hardware Connections

Obviously, for internet radio to work, the Pi has to be connected to the internet. I used a regular Ethernet connection to the Pi, since there is less variance due to interference in the overall network. Of course, you can of course use the WiFi adapter, if you do not have an Ethernet connection close to the Pi.

For the sound connection, I connected the Pi via HDMI to a receiver that I have. You can connect the Pi to your TV and listen from it if that is what you have.

Operating System

For the operating system, I installed Raspbian Jessie using the default NOOBS on the MicroSD card that came with the kit.

Update The Operating System

First order of things, make sure you do a full software update before you proceed, as follows:

sudo aptitude update
sudo aptitude full-upgrade

Configuring ALSA Sound

Then make sure that you have a file called /etc/asound.conf, with the following in it:

pcm.!default {
        type asym
        playback.pcm {
                type plug
                slave.pcm "output"
        capture.pcm {
                type plug
                slave.pcm "input"

pcm.output {
        type hw
        card 0

ctl.!default {
        type hw
        card 0

Mopidy - a music player

For a music player that can stream content, I found that Mopidy is available for the Pi, and is very well documented.

To install Mopidy, use the following command:

sudo aptitude install mopidy

Once you install mopidy, you need to configure it for Internet streams (internet radio stations), and enable the MPD component for it, so you can control it from another device.

In the file /etc/mopidy/mopidy.conf, add the following section:

hostname =

hostname =

output = autoaudiosink

Creating Playlists for Radio Stations

Before you can start to stream radio stations, you need to create an m3u file for each stations.

First you need to find the stream for the radio station you are interested in. The best site to use, is vTuner. Once you locate the station you are interested in, the green 'Play' link to the far left will contain the link, but not directly. You need to save the link to a file, and in that file there will be the stream you want.

You can do this by using wget, then inspecting the file that it saves (or the stream it tries to play).

After you have identified the stream, you need to create an .m3u entry under the directory: /var/lib/mopidy/playlists/

The format is quite simple. Here is a template:


Here is an example:

#EXTINF:0,CBC Music (Eastern)
#EXTINF:-0,Montreal Classique
#EXTINF:-0,Radio Suisse Classique
#EXTINF:-0,Venice Classic Radio
#EXTINF:-0,CBC Radio 1 (Toronto)
#EXTINF:-0,Radio Classique

Save that to a file in the above directory, and call it something descriptive, and the extension is .m3u, for example: Radio.m3u.

Then restart Mopidy again, like so:

sudo service mopidy restart

MPD Clients

You can have a basic command line client by installing this package:

sudo aptitude install ncmpcpp

If you have an Android phone or tablet, you can install MPD Remote or MPDoid on it, so you can control the player from your phone or tablet.

On an Xubuntu desktop, you can use Sonata or QMPDClient.

Streaming Your Internet Radio

Once you have done the above, you can control mopidy from your Android phone, which should be self descriptive.

Or if you are a command line old timer like me, you can control Mopidy from an ssh session using ncmpcpp. Hit F3, and then hit Enter on one of the channels that you have configured. Use + and - to control the volume, and s to stop playing the station.

Enjoy ...