UPDATE 08/20/2017: community member @Tony_Reimann kindly pointed to the existence of RaSpotify, a fully packaged librespot distribution that was released sometime after this thread was started. While the info below is technically still valid, RaSpotify is the better and easier solution.
Sometimes I like Spotify – mostly for the playlists and the way it seems to know me well enough to cater to my tastes in recommendations. For those running a Pi (or similar SBC) with a HAT, there’s an easy way to add Spotify Connect without compiling and/or getting keys.
That’s all. Spotify Connect will be loaded automatically every time you boot your Pi. It will automatically release ALSA a few seconds after playing is stopped, so RoonBridge can take over (alternately, RoonBridge releases ALSA a few seconds after playing is stopped as well).
Happy listening!
(This little guide was created from an excellent post by Ari at the Hifiberry forums).
It didn’t work for me. I got the following when querying the status
root@DietPi:~# systemctl status spotify-connect.service
● spotify-connect.service - Spotify Connect
Loaded: loaded (/etc/systemd/system/spotify-connect.service; enabled)
Active: active (running) since Fri 2017-01-06 13:09:25 NZDT; 10min ago
Main PID: 454 (librespot)
CGroup: /system.slice/spotify-connect.service
└─454 /root/librespot --name SpotifyConnect --cache /tmp --bitrate 320 --backend alsa --device hw:0 > /dev/null 2>&1
Jan 06 13:14:01 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::107b:6fc5:5605:88d3]:5353): class 32769 is invalid
Jan 06 13:14:01 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::107b:6fc5:5605:88d3]:5353): class 32769 is invalid
Jan 06 13:14:02 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::107b:6fc5:5605:88d3]:5353): class 32769 is invalid
Jan 06 13:14:03 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::107b:6fc5:5605:88d3]:5353): class 32769 is invalid
Jan 06 13:14:03 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::107b:6fc5:5605:88d3]:5353): class 32769 is invalid
Jan 06 13:14:05 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::c25:1f57:8260:6d0c]:5353): class 32769 is invalid
Jan 06 13:14:05 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::107b:6fc5:5605:88d3]:5353): class 32769 is invalid
Jan 06 13:15:42 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::c25:1f57:8260:6d0c]:5353): class 32769 is invalid
Jan 06 13:17:21 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::c25:1f57:8260:6d0c]:5353): class 32769 is invalid
Jan 06 13:18:58 DietPi librespot[454]: WARN:mdns::fsm: couldn't parse packet from V6([fe80::c25:1f57:8260:6d0c]:5353): class 32769 is invalid
You can stop the service temporarily and try device settings by running the above command direct from the prompt until it runs OK – then change the service file accordingly and restart.
I am using a Allo Piano Dac 2.1. The output of aplay -l is
**** List of PLAYBACK Hardware Devices ****
card 0: PianoDAC [PianoDAC], device 0: Piano DAC HiFi pcm512x-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
so looks OK to me. I don’t see any Spotify Connect device at all. Running the command manually gives
root@DietPi:~# /root/librespot --name SpotifyConnect --cache /tmp --bitrate 320 --backend alsa --device hw:0
INFO:librespot::main_helper: librespot 3331338 (2016-12-30). Built on 2016-12-30.
INFO:librespot::main_helper: No username provided and no stored credentials, starting discovery …
WARN:mdns: Error creating IPv4 UDP socket for mDNS: No such device (os error 19)
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::c25:1f57:8260:6d0c]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::1817:83af:9f46:c362]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::1817:83af:9f46:c362]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::1817:83af:9f46:c362]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::1817:83af:9f46:c362]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::4c7:5fc5:c871:fed0]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::4c7:5fc5:c871:fed0]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::4c7:5fc5:c871:fed0]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::4c7:5fc5:c871:fed0]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::4c7:5fc5:c871:fed0]:5353): class 32769 is invalid
WARN:mdns::fsm: couldn’t parse packet from V6([fe80::4c7:5fc5:c871:fed0]:5353): class 32769 is invalid
@Tony_Reimann that seems to be rather network issue than DAC issue. Possibly some sort of ipv6 or mdns incompatibility - possibly upgrade of OS could help?
Diet-Pi is amazing and I’m just heading over to add a few spondulicks to the budget.I know I only cut and pasted to get Spotify connect but it feels like magic to me!
Unfortunately this may mean quite a few silly questions may be asked here going forward!
It sure does have internet connectivity (needed it to get the s/w in the first place ) Running the latest dietpi 1.41. Here is the ping of google just to prove internet connectivity
root@DietPi:~# ping www.google.com
PING www.google.com (216.58.199.36) 56(84) bytes of data.
64 bytes from www.google.com (216.58.199.36): icmp_seq=1 ttl=54 time=30.9 ms
64 bytes from www.google.com (216.58.199.36): icmp_seq=2 ttl=54 time=30.6 ms
64 bytes from www.google.com (216.58.199.36): icmp_seq=3 ttl=54 time=30.6 ms
64 bytes from www.google.com (216.58.199.36): icmp_seq=4 ttl=54 time=30.7 ms
64 bytes from www.google.com (216.58.199.36): icmp_seq=5 ttl=54 time=32.2 ms
64 bytes from www.google.com (216.58.199.36): icmp_seq=6 ttl=54 time=30.5 ms
64 bytes from www.google.com (216.58.199.36): icmp_seq=7 ttl=54 time=30.5 ms
64 bytes from www.google.com (216.58.199.36): icmp_seq=8 ttl=54 time=30.6 ms
64 bytes from www.google.com (216.58.199.36): icmp_seq=9 ttl=54 time=30.5 ms
64 bytes from www.google.com (216.58.199.36): icmp_seq=10 ttl=54 time=30.6 ms
^C
— www.google.com ping statistics —
10 packets transmitted, 10 received, 0% packet loss, time 9015ms
rtt min/avg/max/mdev = 30.572/30.838/32.218/0.509 ms
I am stumped and want spotify connect so I really appreciate any help.
Could it be an issue with me using a Kali reclocker with the piano 2.1 dac?
I ended up in a similar situation this morning after updating RoonBridge – so I guess the coexistence between the two is not yet as peaceful as we’d like.
Things stabilised after stopping the spotify-connect.service, restarting roonbridge.service and starting spotify-connect again. Lets see how this works out over time.
In the mean time I’ll add a spare Pi + Digi+ board running Librespot exclusively to the mix, as I found it to be more reliable and better sounding compared to the Chromecast Audio that was assigned to Spotify duty until now.
cool, thanks Rene!
Now just to figure out a way to control the volume on the Dion Audio Loco DAC/Amp on the Pi… alsa doesn’t show anything that I can do and this thing can be loud…
You won’t really need those services (I have since removed them from the first post) – this was me trying to make starting the service more reliable, but it looks like the embedded mDNS code is the culprit.
thanks for the great writeup/help, however I have one issue within my setup, although the Spotify App on my Android phone sees the Spotify Connect option, however when I choose it and press play I get no sound via the Sparky/Piano/Kali setup.
Roon bridge is working fine and sounds great however Spotify connect is running but with no output ( Spotify connect volume is max )
Internet connection is all good as I can listen to the radio stations via net connection