Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

The Raspberry Pi 2 as an Internet Radio using Mopidy

  1. Home

By Khalid on 2016/02/12 - 20:53, last updated 2021/03/15 - 20:22

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:

[mpd]
hostname = 0.0.0.0

[http]
hostname = 0.0.0.0

[audio]
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:

#EXTM3U
#EXTINF:0,NAME OF RADIO STATIONS
STREAM

Here is an example:

#EXTM3U
#EXTINF:0,CBC Music (Eastern)
http://cbcmp3.ic.llnwd.net/stream/cbcmp3_cbc_r2_iet
#EXTINF:-0,Montreal Classique
http://www.radioking.com/play/radio-classique/271810
#EXTINF:-0,Radio Suisse Classique
http://stream.srg-ssr.ch/m/rsc_fr/mp3_128
#EXTINF:-0,Venice Classic Radio
http://174.36.206.197:8000/stream1
#EXTINF:-0,CBC Radio 1 (Toronto)
http://cbcmp3.ic.llnwd.net/stream/cbcmp3_cbc_r1_tor
#EXTINF:-0,CFMZ
http://34.82.236.16/mzmedia-cfmzfmmp3-ibc2
#EXTINF:-0,Radio Classique
http://broadcast.infomaniak.net:80/radioclassique-high.mp3

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

Contents: 
Technology
Linux
Tags: 
Raspberry Pi
Music Player
Internet Radio
  • Add comment

Comments

Jeni (not verified)

Thank you for your important

Wed, 2016/06/22 - 01:21

Thank you for your important additions.

  • reply

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.