WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Spotify connect (librespot) on piCore  (Read 236 times)

Offline Gerrelt

  • Full Member
  • ***
  • Posts: 177
Spotify connect (librespot) on piCore
« on: February 16, 2019, 11:06:48 AM »
Hi all,

I've got Spotify connect with librespot working on piCore, and I wanted to share how I did it.
With librespot running, your raspbery pi will show up in the Spotify app under "devices available".
When selected, the song will be played on your raspberry instead of your phone.
(NOTE: I believe this does not work with a free spotify account)

Librespot uses "libportaudio2" which wasn't available on piCore, so I compiled it, and made a .tcz package for it.
To get it all running, execute these commands:

Code: [Select]
mkdir librespot
cd librespot
# libportaudio2 compiled and packaged by me, and source downloaded from:
#     http://www.portaudio.com/download.html
wget http://www.gerrelt.nl/RaspberryPi/libportaudio2.tcz -P /mnt/mmcblk0p2/tce/optional
sudo echo "libportaudio2.tcz" >> /mnt/mmcblk0p2/tce/onboot.lst
# librespot compiled by me, and source downloaded from:
#     https://github.com/librespot-org/librespot
wget http://www.gerrelt.nl/RaspberryPi/SpotifyRadio/librespot.tar.gz
tar -xvzf librespot.tar.gz
sudo mv librespot /mnt/mmcblk0p2/tce
chmod u+x /mnt/mmcblk0p2/tce/librespot

To start it at boot, you will have to choose a soundcard first.
Code: [Select]
aplay -lor
Code: [Select]
cat /proc/asound/cards
And see wich soundcard number and device number you want to use.

Open bootlocal.sh:
Code: [Select]
sudo nano -\$\icwS /opt/bootlocal.sh
And add this line to the end:
Code: [Select]
/mnt/mmcblk0p2/tce/librespot --name YourSpotifyConnectDevicename --cache /tmp --bitrate 320 --initial-volume 100 --backend alsa --device hw:0,0 > /dev/null 2>&1 &
Now, change "--device hw:0,0" to the choosen soundcard and device number, this example uses soundcard 0 and device 0.

Also check if you want to set the initial volume to 100%. If you adjust volume by a physical volume knob, you probably want it set to 100. If you use a software "volume knob", you probaly want to set it to something a lot lower.  ;D
See option "--initial-volume 100" to change it.

You will also want to change "--name YourSpotifyConnectDevicename" to give your device a recognizable name.

Exit nano with CTRL-X, save the file, and make all your changes persistent by executing:
Code: [Select]
filetool.sh -b
Reboot your raspberry pi, and when booted, it should appear under "devices available".

Enjoy! 8)

« Last Edit: February 16, 2019, 11:11:20 AM by Gerrelt »
my Raspberry Pi page: http://raspberry.gerrelt.nl