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@ 
  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
//  streamUris.push(['', '']);
streamUris.push(['Swiss Jazz', '']);
streamUris.push(['Swiss Classic', '']);
streamUris.push(['Swiss Groove', '']);
streamUris.push(['WeFunk', '']);
streamUris.push(['Sputnik', '']);
streamUris.push(['Bayern Klassik', '']);
streamUris.push(['Bayern Nachricnten', '']);
streamUris.push(['Byte FM', '']);
streamUris.push(['Klassik Radio 96', '']);
streamUris.push(['88.6 Wien', '']);
streamUris.push(['Edge Movie Sountracks', '']);
streamUris.push(['Edge Oper', '']);
streamUris.push(['Edge Lounge', '']);
streamUris.push(['Ö1 Live', 'mms://']);
streamUris.push(['Ö1 Info', 'mms://']);
streamUris.push(['FM4', '']);
streamUris.push(['SuperFly Wien', '']);
streamUris.push(['BBC WorldService', '']);
streamUris.push(['Groove Salad - Soma FM', '']);
streamUris.push(['Kiss FM Berlin', '']);
streamUris.push(['Diva Radio', '']);

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.





Continue reading