Blog

 

Using Spotify with HiFiBerryOS

Spotify is the most popular music streaming service worldwide. While the app for smartphones and personal computers works quite well, Spotify doesn’t officially provide a “headless” player that could be used in a system like HiFiBerryOS. Additionally, some people might prefer open-source software. Herein lies the problem: Spotify doesn’t support this, lacking an official API to stream songs to an open-source player. The good news is that there are various open-source projects that have reverse-engineered the Spotify protocol, allowing the provision of Spotify functionality on Linux with open-source software.

With the new HiFiBerryOS64, we have drastically changed the architecture of our own music player distribution. The shift to 64-bit improves support for newer Raspberry Pis, but there’s another change that’s even more important for the future: Our new extension system allows us and other developers to more easily create software that runs on HiFiBerryOS without the need to fully rebuild the system. Let’s see what this means for Spotify playback.

Note that the following guide works only with the latest HiFiBerryOS64. You can get the latest version from GitHub.

The standard Spotify player: Vollibrespot

Vollibrespot has been a part of HiFiBerryOS for a long time. It supports the control of the player from the UI and can display metadata of the song currently playing. Generally, it works quite well. However, some users have reported problems playing specific albums. Since we are not the developers of this software and lack in-house Rust expertise (the programming language used for this project), we unfortunately can’t debug these issues or fix them. If it works for you – great. Otherwise, there are some alternatives now.

The alternative: Spotifyd

Spotifyd has been a long-standing popular Spotify player. It was our standard player for some time. Due to issues with the player hanging after some time without music playback, it was replaced by Vollibrespot. However, a lot of work has been done, and it might work better today for some users. We still see playback interruptions after some time, but this might not be the case for other users.

Before trying Spotifyd, make sure you disable the “Spotify Connect” player in “Sources,” as multiple Spotify players on the same system won’t work together.

Spotifyd comes as an HBOS extension. It will be installed automatically on the first start of HiFiBerryOS. However, extensions are downloaded and installed from the Internet. If your system wasn’t connected to the Internet, the player might not yet be available. To check and manually install it, go to the next “Extensions” screen under the “General” menu. Here you can see all available extensions:

If Spotifyd isn’t enabled, you can just click the checkbox. As this might require downloading software from the Internet, it can take some time – especially if your Internet connection is slow. Just be patient. Once the extension has been installed and started, you will find it under “Sources,” and you can configure it there. You should configure your Spotify username/password as the metadata support will probably not work without this.

A different way: Spotify in Logitech Media Server

And there’s a third way: Logitech Media Server. The project has been renamed to “Lyrion Music Server” as Logitech no longer supports it, and it’s now a community project. But the software still appears as “Logitech Media Server.” This software was developed and used by Logitech for a long time for their Squeezeboxes. While the user interface looks a bit dated, it’s still quite popular as this open-source music server supports synchronous playback to multiple clients.

Integrating Spotify with it is a bit more complex:

  • Install the Logitech media server extensions.
  • Configure LMS. Connect to http://name-or-ip-of-your-system:9000 and complete the initial setup. Under “Settings/Manage Plugins,” you can add the Spotify plugin. Follow the instructions of this plugin to log in to Spotify.

The Logitech Media Server doesn’t offer any audio functionality. It only distributes music to players. Therefore, you have to add a player. This is “squeezelite,” which also comes as a plugin. Install and enable it. Now you can select the player in the player list in the upper-right corner of the LMS GUI.

There is a major difference compared to the previous players: This extension doesn’t support Spotify Connect. It will import your Spotify library into the Logitech Media Server. To control playback, you need to use the LMS GUI or a Squeezebox control app like iPeng.

And another one: Airplay

If you’re using an iPhone, you can just use the Airplay functionality. The player “shairport-sync” has also been converted to an extension and updated to the latest version. One disadvantage compared to the previous methods: The music will be streamed to your iPhone first and then distributed from there to the speakers. This will consume battery energy. In many cases, that’s not really an issue. So, feel free to try.

As with HiFiBerryOS in general, we’re always interested in feedback. However, we can’t provide individual support for it nor can we guarantee that a specific player works in your environment. Feel free to use our forum, but do not send us emails or open service requests if something isn’t working as you expect. Check out the support guidelines of HiFiBerryOS.

April 14, 2024

Subscribe to new blog posts