Pages

Tuesday, August 22, 2017

Creating a Raspberry Pi Squeezebox server

Frustration with Spotify

In my last blog post I wrote how Spotify remotely deleted their app from my Squeezeboxes. This pissed me off and I wondered who was in control of the Squeezebox devices, me or some third party. It forced me to choose between the service mysqueezebox.com, that streams music from the internet, or set up the Squeezebox server on my network. The Squeezebox server software being free and open source software guarantees that I take control of my Squeezeboxes and the music that I'm streaming.

The're many hardware options for the Squeezebox server software (or Logitech Media Server) but I decided to use the Raspberry Pi 2 that I had lying around because of it's small footprint and massive support for the Pi. Within a couple of hours I had the Logitech Squeezebox Server up an running with my music playing.

Below I'll show the steps that need to be taken to set up the Logitech Squeezebox Server on the Raspberry Pi. I got some important steps from the Variax Firmation website but I tested everything.

Raspberry Pi 2 with a USB-harddrive connected to my network with an ethernet cable.


Step 1: Ripping CD's and writing them on an HDD (choosing an audio format)

Before setting up a server rip the CD's and write them to a HDD. For this project I used a small usb-harddrive that was also lying around. I formatted the HDD as FAT32. Next I collected all my music CD's and ripped them. As ripping software I used the Asunder software on my Tahrpup Linux system (6.0.5) but I guess that the're good alternatives. As audio format I choose mp3 for now. If I buy a larger drive I'll probably move to flac.

Step 2: Installing Raspbian Stretch Lite

Next I installed the just released Raspbian Strech Lite on the Raspberry Pi 2 by first downloading the image and writing the image to the micro SD card using these instructions.  I chose the lite version of Raspbian Stretch to make the server as lightweight as possible. I had no problems booting the Raspberry Pi and connecting it to my network using ethernet. To avoid potential problems connect the Pi to a monitor with an HDMI cable and make sure that it boots properly.

Step 3: Mount the HDD on the Raspberry Pi

Now with Raspbian Lite installed I mounted the HDD that we prepared in step 1 we need to login remotely and retrieve the name of the drive. To login remotely we need another computer (Windows, Linux or OSX). Open a terminal (or Putty in case of Windows) and type
sudo ssh pi@Raspberry_Pi_ip_address (in my case 192.168.178.69)
The password is raspberry. Then type.
sudo fdisk -l
Then look for the HDD that is just connected. This was /dev/sda1 in my case (but this may differ in yours). To make the files on the HDD accesible to the Raspberry Pi we need mount the drive. But before that we need to make a mounting point.
sudo mkdir /media/usb-drive
and mount
sudo mount /dev/sda1 /media/usb-drive
You should hear some HDD activity. Now type
cd /media/usb-drive ls -l
and a list of your music should be visible.
To unmount the HDD do
sudo umount /media/usb-drive

The list of folders with albums that I ripped. In this stage I only ripped a few albums to test the system.

Step 4: Installing Logitech Media Center on the Raspberry Pi

Before we need to install a library to play audio files.  Since you want mp3 only do:
sudo apt-get install -y libsox-fmt-all
This installes SoX, a command line utility that, among other things, plays various types of audio files. If you want to add flac support you'll probably need to do this
sudo apt-get install -y libsox-fmt-all libflac-dev
Now with the audio libraries in place the Logitech Media Software can be downloaded. We want the latest version which is 7.9.0.
wget -O logitechmediaserver_all.deb $(wget -q -O - "http://www.mysqueezebox.com/update/?version=7.9.0&revision=1&geturl=1&os=deb")
Now install the server software with:
sudo dpkg -i logitechmediaserver_all.deb
With all the software installed we're ready to go.

Step 5: Working with Logitech Media Center

To enter the web interface of the Logitech Media Center on the Pi we need a computer and a browser. In the browser url we type:
<your_Raspberry_Pi_ip_address:9000> (in my case 192.168.178.69:9000) 

The Logitech Media Center is started for the first time and a script is started to set it up. Important is that the mounting point of the HDD (in my case /media/usb-drive) is entered. This way the Media Center is able to retrieve all the music files.
sudo mkdir /media/usb-drive
The Logitech Media Server is now ready and every time the Raspberry Pi boots the Logitech Media Server is automatically started however the HDD is not automatically mounted so we need to change that. This is done in the fstab system configuration file that can be found at /etc/fstab
sudo nano fstab
and add the following line
/dev/sda1    /media/usb-drive     vfat&    defaults     0
Save the file and exit nano. Reboot the Raspberry Pi. Now the installation is complete. The music can be played from the web interface (see above), with the remote controls that come with the Squeezebox devices or with a free app for Android. The Squeezebox Radio also has controls on the device to play the music. So, plenty of options.

Webinterface of the Logitech Media Server.

What's next

To give the media server a permanent place a case is needed. Luckily I have a 3D printer and some 3D CAD skills so I'll create my own. I'll show the finished product in a future blog post. I also wonder if I could make this work on the C.H.I.P which would make the project even cheaper.
 

No comments:

Post a Comment