Wednesday, September 16, 2020

Raspberry Pi Audio Streaming Server

There are many prepackaged audio streaming servers available for the Raspberry Pi. Between Moode, Volumio, and piCorePlayer, piCorePlayer is very rich in its capabilities. It can access local media as well as a huge list of free online streaming content including TuneIn. piCorePlayer has also been the most stable where stable is defined to the quality of having a longer uptime. Although piCorePlayer is the most stable, I have occasionally encountered a loss of connectivity to the pi system (through the web interface and SSH). piCorePlayer also touts having a fast boot due to the use of Tiny Core Linux, but I experienced boot delays of greater than 30 seconds.

Granted that I could have spent time debugging why I lost connectivity and why boots took longer than 30 seconds, I decided to take another approach. Rather than using the prepackaged piCorePlayer which is convenient with its one-button push approach, I manually installed Logitech Media Server and Squeezelite player on Raspbian.

Here are some of the differences I see versus piCorePlayer.

  • I can access the LMS web interface using the hostname rather than the IP. ie. I don't need to assign a static IP to the server. See Resolve Linux Hostnames in Windows.
  • Booting the system takes less than <10 seconds.
  • The server has been rock solid.

Here are the steps for the setup.

Install Base Raspbian

Install the base Raspbian distribution. There are many instructions on the web on how to do this. If you want to be able to access LMS web interface using the host name, make sure you assign a host name to the system during setup.

Install Squeezelite

Install the Squeezelite package.

sudo apt-get install squeezelite

Identify the desired audio output device for Squeezelite.

squeezelite -l

Create a squeezelite service file.

sudo vi /etc/systemd/system/squeezelite.service

Paste the following contents into the file.

[Unit]
Description=Squeezelite

After=network.target

[Service]
ExecStart=/usr/bin/squeezelite -o hw:CARD=T1E,DEV=0 -n living_room -s 127.0.0.1

[Install]
WantedBy=multi-user.target

Here hw:CARD=T1E,DEV=0 is the name of the ALSA output device, living_room is the name assigned to the Squeezelite player, and 127.0.0.1 is the IP of the LMS server. Since Squeezelite and LMS will run on the same system, I'm using the loopback address.

Start the new service on boot.
sudo systemctl enable squeezelite.service

Install LMS

sudo apt-get install libio-socket-ssl-perl libnet-libidn-perl libnet-ssleay-perl perl-openssl-defaults
cd
mkdir lms
cd lms
wget http://downloads.slimdevices.com/nightly/8.0/lms/5949ad56255da8462b0e9f9fd6153acba5a7a7b3/logitechmediaserver_8.0.0~1600144351_all.deb
sudo dpkg -i 8.0.0~1600144351_all.deb

I'm running LMS 8.0 as of this writing.

Final Setup

Reboot your system.

sudo reboot

Point your web browser to the following URL.

http://<hostname or IP>:9000

Upgrading LMS

sudo dpkg -r logitechmediaserver
sudo dpkg -i logitechmediaserver_<xxx>_all.deb

References

Installation Instructions from John's Tech Blog
Installation Instructions from Winko Erades' Blog
Latest Squeezelite Builds

No comments: