Spotify Options for Raspberry Pi in 2024

Hello Pimoroni gurus,
I’m having a blast with a Pirate Audio, successfully jamming with Mopidy loading local files. I’m pairing it with a Raspberry 2 W running Raspberry Pi OS (Legacy, 64-bit [Debian Bullseye 2024-03-12]). My hope is to make this a tactile music experience for my little one who is curious about different genres (plus it’s FUN to make). We’re finding the voice interfaces not as exploratory.

I’m leaning towards making use of Spotify under the hood, yet I understand the old abandoned Spotify library and am experiencing an adventure of other disjointed connectivity (with some progress). A bit has changed since issue 17. I don’t really need any solid answers here, yet I could cover those adventures and see if anyone has cool ideas?


I started with the Pirate Audio install script and Modipy/Iris. The guide was great. It was neat to load up the device-hosted website and explore local files once loaded. I’m not excluding this as an option. I just don’t own a lot of digital files to throw in there right now.

On the Spotify track, I looked at Mopidy-Spotify. Although, Spotify seems installed in Iris for browsing, which was confusing. Installing Mopidy-Spotify wasn’t so bad yet it now depends on a gstreamer plugin, gst-plugins-spotify. I first went the route of trying to build from source, however the install process froze my poor little Pi a couple of times, requiring reboots. I then installed “successfully” from a debian package file (the armhf one). However, the plugin didn’t seem to register with gstreamer. I can expand on this if there’s interest.


Then I thought, why not start from the basics with librespot that powers a couple of the options? After a couple of rough install attempts, I settled on librespot-dev instructions. This got me very close to successfully streaming Spotify (haven’t checked if I could control Spotify with it yet). It successfully creates an instance that is visible to stream to in Spotify. I can start the stream with no visible error. I just don’t hear anything, yet. I can return to this and fiddle with the “device” option perhaps (learned more about this later).


I jumped over to Pimoroni’s PiDi Spotify beta powered by Raspotify, a fork of librespot. With the Raspotify install, I’m noticing a few significant changes over the last four years since PiDi Spotify was last updated. Mainly, centered around the config file that moved to /etc/raspotify/conf, with updated options and prefix to each variable. I was able to get this running mostly (can expand on this as needed/if there’s interest) and I can once again see a device listed in Spotify that can be streamed to. Clicking that device in Spotify triggers an error that kills the connection immediately. It could* be related to the device option of LIBRESPOT_DEVICE="hw:1,0". It could also be an RPI.GPIO odd thing I’m seeing (“RuntimeError: This module can only be run on a Raspberry Pi!”). I figured it was time to see what others were doing these days…


I avoided posting a bunch of logs and such here as this is not a Pimoroni bug report. The Pirate Audio device works great and I received my money’s worth (looking forward to hacking at the screen too!).

I’m mainly curious about what others are doing with Spotify today. It seems like activity was huge then Spotify killed their dead library in 2022 (unsupported since 2016). Then new options came out yet still feel fragmented, at least for me at the moment and I’m not the expert.

I still have hope. Any ideas on how to make use of Spotify in 2024 on a Pi?

Thanks for letting me ramble and have an awesome day/night.


Update: For memory before I wipe my Pi and try again:

librespot -n "Librespot" -b 160 -c ./cache --enable-volume-normalisation --initial-volume 20 --verbose --username MY_SPOTIFY_USERNAME --password MY_SPOTIFY_PASSWORD --device "hw:1,0"

Result (yet raspotify is also running at the same time now, will start over soon):

Audio Sink Error Connection Refused: <AlsaSink> Device hw:1,0 May be Invalid, Busy, or Already in Use, ALSA function 'snd_pcm_open' failed with error 'ENOENT: No such file or directory'

OhH!! I’m now streaming Spotify!

librespot -n "Librespot" -b 160 -c ./cache --enable-volume-normalisation --initial-volume 20 --verbose --username MY_SPOTIFY_USERNAME --password MY_SPOTIFY_PASSWORD

(don’t set device)

But also add in /boot/config.txt (I lost these settings with a wipe/reset/reinstall):

dtparam=audio=off
gpio=25=op,dh
dtoverlay=hifiberry-dac

update: It looks like respotify is working as well after reboot (boot config ftw).

Now I need to revisit controlling Spotify from the Pi and revisit PiDi Spotify and its coolness when working with ONEVENT scripts. Progress. Maybe I can post a pull request soonish once I figure this stuff out?

2 Likes

Controlling Spotify with GPIO button press or other sensor thing:

I’m not sure if this will be an option. It seems like I need the web sdk as part of this (confirming, not sure yet). Maybe I focus on local audio (with or without mopidy) and just use a phone Spotify client or other computer to trigger streaming to the device. I’m open to ideas there if you think of anything.

update: A combination of spotifypi and flask might do the trick:

Another approach is LMS (Lyrion Music Server - Logitech Media Server as was) with its “Spotty” plugin.
It uses Librespot.
You get a full system with documented API (to LMS) and a lot of plugins for other things.

1 Like

Thanks @PaulWebster! I’m fascinated that I’m seeing Perl changelog commits from 19 years ago yet also last week. I’ll check it out for sure to see what it can do. :)

I released an update for one of the available plugins last week ;)

1 Like

🤩

Awesome!! What a project and great history as I dig a bit more. Thanks for all your efforts there. I’ll be sure to check it out this weekend in more detail.

So far I’ve been getting my little one involved and this project is taking a few pivots as I learn what is drawn to. For much of my planning, I’ve been thinking Spotify control from the boombox because that’s cool (in my eyes). However, there’s a desire to move around with this device offline in the back yard, the playground, etc.,. There’s an interest in very specific songs, in addition to others I’ll add of course to make introductions to several new types of music, my devious plan.

Remember carrying around a boombox on your shoulder as you strut through town? (Not me actually yet I did have a small cassette player where I played one tape over and over again until the tape mysteriously disappeared one day…) It’s that tactile, offline experience that might be enjoyed best. With that, I’m leaning towards RFID “albums” that trigger offline mp3s and/or playlists. I tested a small USB battery with the setup and it lasts a good four hours at near-highest volume before needing a charge!

Maybe for the Pirate Audio screen I don’t even worry about showing titles because my little one will have them in physical cardstock form (with RFID sticker on the back). I could show fractals during playback or something. I have nearly all the parts for this (Pimoroni Nano Hat Hacker in the mail to help break things out).

Then since I already have Spotify connected as a streamable device, I could connect to it for the sleepy time playlist or specific requests. That may save me the need for an extra Spotify account and offer more kid song suggestions in my new release playlist (oh no…).

I’ll be sure to share whatever I come up with. I’m revisiting rusty Blender skills to design a boombox shell. There are a few others out there, yet I’m an artist and want to make one as well. :D

Here is a worked example (not Spotify or LMS but should be easy to extend if needed).

1 Like

Wow! I knew there were other RFID music projects out there, yet I didn’t realize the amount of interest. Thanks for that link! ❤️