WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline Gerrelt

  • Full Member
  • ***
  • Posts: 178
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.
Execute:
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

Offline Gerrelt

  • Full Member
  • ***
  • Posts: 178
Re: Spotify connect (librespot) on piCore
« Reply #1 on: April 28, 2019, 12:31:47 PM »

For who is interested in this...:

I had some problems with tracks not starting or skipping to the end of the songs, so I compiled Librespot again with the latest sources.
This solved it for Raspbian, but not for piCore.
It turned out the problem was that I didn't set the timezone on my piCore installations. You can check by executing the "date" command and compare it to the actual time.
After some (long) searching I found how to set the timezone.

I set it like this:

Code: [Select]
mount /dev/mmcblk0p1
Open cmdline.txt it in nano:

Code: [Select]
sudo nano -\$\icwS  /mnt/mmcblk0p1/cmdline.txt
And add to the end (with a space before it to seperate it from the other settings):

Code: [Select]
tz=CET-1CEST,M3.5.0,M10.5.0/3‚Äč(NOTE: this is for Europe/Amsterdam)
Save and close the file and do a backup:

Code: [Select]
filetool.sh -b
After a reboot the timezone was correct and Spotify connect worked correctly again.

Sidenote, you can check wat the tz string should be if you have a Raspbian installation:
Code: [Select]
cat /usr/share/zoneinfo/Europe/AmsterdamThis will produce some garbage, but in between it will mention the timezone string.
my Raspberry Pi page: http://raspberry.gerrelt.nl

Offline mickeyarthy

  • WikiUser
  • *
  • Posts: 1
Re: Spotify connect (librespot) on piCore
« Reply #2 on: June 08, 2019, 08:32:32 PM »
This feature makes spotify playback easy with picoreplayer.
Thanks to Mr. Gerrelt for sharing this setup.