Persist Web Radio Streams in the Pi MusicBox

After upgrading my Raspberry Pi Model B to the new Raspberry Pi 2 a few weeks a go, I finally found a new purpose for the old device. There exist several images for the Pi with a focus on with Internet radio streaming. After doing a little research, I decided to use the Pi MusicBox, which comes with a headless audio player and supports a whole lot of different sources and formats: Spotify, SoundCloud, Google Music, Podcasts (with iTunes, gPodder directories), local and networked music files (MP3/OGG/FLAC/AAC), Webradio (with TuneIn, Dirble, AudioAddict, Soma FM directories), Subsonic. The system is rather easy to setup, descriptions are available at the project homepage. The Pi MusicBox comes with a nice responsive Web interface which allows browsing and your music sources via SD card, USB drive or even network shares. Additionally you can integrate your music streaming services.

So I finally upgraded my kitchen radio by attaching the Pi via its analogue audio outlet. Of course this is nothing for audiophiles, but neither are Web streames usually. I am quite happy with the quality. All I needed was a the raspberry pi, a phone charger. a 1GB SD card, the Edimax Wifi Dongle and a audio cable for my radio. The setup is straightforward, although it took a few attempts to put the image on the SD card. You then just need to enter the Wifi connection data and boot the device. The boot process is rather slow, even compared to other raspberry pi operating systems. If you plan to use your Android phone for controlling the streaming services, you should consider providing a static IP as Linux doesn’t always support zeroconf out of the box.

Another thing which needs tweeking is the list of Web radios. Currently the software does not store them persistently on the drive of the pi, but rather in your browser. Therefore you do not have access previously stored radio stations on alldevices or if you change your browser. Adding the radio streams persistently is fortunately very easy.

  1. Navigate to the settings section in the Web interface and select MusicBox. Activate SSH and assign a root password.
  2. Reboot
  3. Connect via ssh to the device by using the password you just specified
     ssh root@192.168.0.5 
  4. Search for a preconfigured radio station to find out where the systems stores the URIs
    root@musicpi:~# grep -r "WorldService" /
  5. Edit the file and add your favorite radio stations
    root@musicpi:~# nano /boot/config/streamuris.js 

The radio stations are now available in the Web interface for all your devices. The file should looke like this:


//root@musicpi:/# cat boot/config/streamuris.js
/**
* Default streamuris which appear in the webinterface. Edit if you like.
* Take care when editting. Only edit the stuff between ''
* And don't use the default Windows Notepad for this (use Notepad++ on Windows)
*/

var streamUris = [];
//fill with defaults
//template:
//  streamUris.push(['', '']);
streamUris.push(['Swiss Jazz', 'http://www.radioswissjazz.ch/live/aacp.m3u']);
streamUris.push(['Swiss Classic', 'http://www.radioswissclassic.ch/de/live/aacp.m3u']);
streamUris.push(['Swiss Groove', 'http://184.154.202.243:8053/']);
streamUris.push(['WeFunk', 'http://www.wefunkradio.com/play/radio.pls']);
streamUris.push(['Sputnik', 'http://www.sputnik.de/m3u/live.hi.m3u']);
streamUris.push(['Bayern Klassik', 'http://streams.br.de/br-klassik_2.m3u']);
streamUris.push(['Bayern Nachricnten', 'http://streams.br.de/b5aktuell_2.m3u']);
streamUris.push(['Byte FM', 'http://www.byte.fm/stream/bytefm.m3u']);
streamUris.push(['Klassik Radio 96', 'http://edge.live.mp3.mdn.newmedia.nacamar.net/klassikradio128/livestream.mp3']);
streamUris.push(['88.6 Wien', 'http://www.radiostream.de/stream/36889.asx']);
streamUris.push(['Edge Movie Sountracks', 'http://edge.live.mp3.mdn.newmedia.nacamar.net/klassikradiomovie128/livestream.mp3']);
streamUris.push(['Edge Oper', 'http://edge.live.mp3.mdn.newmedia.nacamar.net/klassikradioopera128/livestream.mp3']);
streamUris.push(['Edge Lounge', 'http://edge.live.mp3.mdn.newmedia.nacamar.net/klassikradiolounge128/livestream.mp3']);
streamUris.push(['Ö1 Live', 'mms://apasf.apa.at/oe1_live_worldwide']);
streamUris.push(['Ö1 Info', 'mms://apasf.apa.at/oe1_inforadio_worldwide']);
streamUris.push(['FM4', 'http://mp3stream1.apasf.apa.at:8000/listen.pls']);
streamUris.push(['SuperFly Wien', 'http://89.207.144.68:8080/live']);
streamUris.push(['BBC WorldService', 'http://vprbbc.streamguys.net:8000/vprbbc24.mp3']);
streamUris.push(['Groove Salad - Soma FM', 'http://somafm.com/groovesalad.pls']);
streamUris.push(['Kiss FM Berlin', 'http://stream.kissfm.de/kissfm/mp3-128/internetradio/']);
streamUris.push(['Diva Radio', 'http://195.154.116.117:10780']);

This is the result:

Music Box

 

Alternatively you can also mount the SD card in your PC and edit the file with a little bit more comfort. You will find it in the config folder of the boot partition. Note that you probably have to clear your browser history before the newly added stations become visible.

Remember that the Pi does not have a power button. You can switch if off, but it remains connected to the power source all the time. Nevertheless you are not able to switch it on again afterwards, you need to reset it. The low power consumption is also a reason why the pi is such a nice device for server applications. If you forget to pause or stop the stream, the device will continuously create traffic. Therefore it might be a good advice to limit the connectivity during the night for instance or for using a timer clock.

Update (13.03.2016)

The Music Pi now moved into the living room and I connected it via HDMI my Yamaha RX receiver. No settings need to be adapted, after rebooting, the Pi will automatically use the only connected port, which is now the HDMI port instead of the analog output. Now being fully digital, the fidelity of the sound improved audibly and we now enjoy Radio Swizz Jazz every morning. Now the quality is really nice and a huge joy.

 

 

 

 

5 thoughts on “Persist Web Radio Streams in the Pi MusicBox

  1. Hallo Stefan,
    danke, das hat mir schon sehr geholfen! Ich habe erfolgreich einige Sender hinzugefügt.

    Ich verwende auf meinem Android Handy “MPDroid”, um die Pi Musicbox zu steuern. Wenn ich dort unter “Streams” gehe, sehe ich zwar, was gerade gespielt wird, aber ich sehe keine der anderen Sender, kann somit nicht umschalten.

    Weißt du dazu vielleicht irgendwas?

    LG

  2. Danke 🙂
    Very clear and fortunately we have similar taste, so I could just copy and paste your list of streams, I was just lokking for adding Radio Swiss Jazz.

Leave a Reply

Your email address will not be published. Required fields are marked *