Raspotify
Website of the software: https://github.com/dtcooper/raspotify
With this software you can stream music from Spotify. It is a Spotify Connect receiver. It is meant for a “headless” Linux system, meaning there is no keyboard/mouse/monitor attached. You need a Spotify Premium account to use this.
How to use
What you can do in practice:
- You can use the Spotify app on e.g. your TV, laptop or phone
- Select your Raspberry Pi as playback device in the app
- Now you can control what is played on the Raspberry Pi from the Spotify app
- Raspotify on your Raspberry Pi streams the music directly from the internet
Installation
sudo apt-get -y install curl
curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
This executes an installation script that also adds a Debian package repository for the software. That way you can update it with apt afterwards. (See also Linux: software packages.)
ALSA loopback
In my use case I don't want Raspotify to directly output the audio to a playback device. Instead I want to connect it to an ALSA loopback device. See page Linux: audio about what it is.
This allows me to select either the music from Spotify or my TV as input in CamillaDSP. With the configuration below I can use dsnoop:Loopback,1,0 to get the sound from Raspotify. The sound from Raspotify is always 16 bit (format S16LE) with sample rate 44.1 kHz.
Configuration
Edit the following lines in /etc/raspotify/conf:
BITRATE=320 # Highest possible quality
LIBRESPOT_NAME="Raspberry Pi Jarkko" # Change to what you want
LIBRESPOT_DEVICE="hw:Loopback,0,0" # Send audio to ALSA loopback
Then restart the Raspotify service:
sudo systemctl restart raspotify