[HowTo] Spotify-Connect support via Raspotify (LibreSpot)

many thanks for fast reply ! now I can see it … but I cannot see the OSMC device appearing.


thank you very much for the article. Raspotify works great! Regarding the limitations: unfortunately, even when I pause Spotify playback before playing a movie on Kodi, the sound doesn’t get switched. Please, is there any workaround for the issue? I don’t mind if the workaround involves running some sh scripts, I just don’t want to reboot the system every time that happens.


Hey Martin,

I made the test on the last stable OSMC/kodi on a Vero 4k and the music stops when I start to play a movie.

Why pause? First post says to stop.

It may work without stopping but in my case it didn’t. So I always stop the music first.

Hi I have Spotify Premium and am running OSMC on a Raspberry Pi 2. I have gone through the Automatic Setup process at the top of this thread and the installation finished successfully. I then went into the config file and updated the Device name and put in my Spotify username and pwd details.

I am able to see OSMC as a device to connect to using Spotify Connect. I am also able to connect to OSMC, I am able to start music playing, but after 20-30 seconds it stops and doesn’t come back. I logged into OSMC by SSH and checked the status of Raspotify and it gave me the following:

Feb 25 14:51:47 OSMC librespot[582]: INFO:librespot_playback::player: Loading track “Outlander - The Skye Boat Song (After Culloden)”
Feb 25 14:51:57 OSMC librespot[582]: INFO:librespot_playback::player: Track “Outlander - The Skye Boat Song (After Culloden)” loaded
Feb 25 14:52:03 OSMC librespot[582]: ALSA lib pcm.c:8306:(snd_pcm_recover) underrun occurred

Has anyone experienced this issue and does anyone know how to fix it?
Thanks in advance :slight_smile:

So after doing some investigating my attention was drawn to this line in the config.

To choose a different output device (ie a USB audio dongle or HDMI audio out),
use --device with something like --device hw:0,1. Your mileage may vary.

Investigating the different device options, I believe that hw:0,1 indicates that you want the audio to be output over HDMI… On a whim I tried setting this in my config for raspotify like so and restarted the raspotify service:

OPTIONS="–username xxxx --password xxxx --device hw:0,1"

Voila! It has been working without issue now for around an hour!! What I don’t understand is why I needed to set this… My understanding is that the default is to output audio over HDMI.

I believe the “device” field was added to Raspotify/LibreSpot recently, I still use an older version.

I will update the Autosetup.sh script to add that to the config.

Btw if you use automatic installer, you can simply enter your credentials and device name in the script and it will add those to Raspotify config. The whole idea is you don’t need to mess around after installing :slight_smile:

Thanks @zilexa that makes sense. So it is a required field in the latest version of Raspotify/LibreSpot.

One other question that I was wondering if you could help me with, I must have missed it but where in the automatic installer script do you add Spotify login credentials? I looked and couldn’t find it…

Thanks again :slightly_smiling_face:

you don’t need login credentials :slight_smile:
the autosetup.sh script only has a field for SpotifyDeviceName. I will add the options HDMI/other to the script to support device type.

Thank you @kcassou and @zilexa for your responses.

Please correct me if I’m wrong but there is not such thing as stopping music on Spotify. Only pausing it.

I have no idea if it was that but after upgrading Raspotify from version 0.10.1 to 0.10.4 the behavior is corrected and everything works as supposed to.

Thank you both for your help!

This worked perfectly for months, but now, although it is visible on my devices I am unable to connect to raspotify- it just says “connecting”

osmc@osmc:~$ sudo systemctl status raspotify

  • raspotify.service - Raspotify
    Loaded: loaded (/lib/systemd/system/raspotify.service; enabled)
    Active: active (running) since Thu 2018-03-29 15:58:29 BST; 33min ago
    Process: 2103 ExecStartPre=/bin/chown raspotify:raspotify /var/cache/raspotify (code=exited, status=0/SUCCESS)
    Process: 2101 ExecStartPre=/bin/mkdir -p 0755 /var/cache/raspotify (code=exited, status=0/SUCCESS)
    Main PID: 2107 (librespot)
    CGroup: /system.slice/raspotify.service
    `-2107 /usr/bin/librespot --name raspotify --backend alsa --bitrate 320 --disable-audio-cache --device hw:1

Mar 29 15:58:29 osmc systemd[1]: Started Raspotify.
Mar 29 15:58:29 osmc librespot[2107]: INFO:librespot: librespot 8971d3a (2017-10-05). Built on 2017-10-05. Build ID: POyxPQVg

Same here…

That’s weird. My 2 Rpi’s with OSMC and librespot are working just fine.

Hi, I tried it today but is does not work on the vero4k. Spotify app shows playback but no sound from the vero4k. Anybody else with this issue? Or do I need to dig deeper and check some logs?


Thanks very much for the how to, in the beginning it worked perfectly. (I followed the manual installation)

Unfortunately it stopped working after a few hours (w/o interference from my side, I really really did not do anything). Now I receive this error message when I check the status. Do you have any ideas what went wrong or how to fix it?

May 06 10:00:43 cheesecake librespot[2053]: ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Access denied
May 06 10:00:43 cheesecake librespot[2053]: ERROR:librespot_playback::audio_backend::alsa: Alsa error PCM open -111
May 06 10:00:43 cheesecake librespot[2053]: ERROR:librespot_playback::player: Could not start audio: Alsa error: PCM open failed

Thanks and best regards,

Sorry, I just noticed that my problem is already described in posts 52-55 (I searched for analogue instead of jack, therefore I had not seen that before). Was there a solution to this problem?

I tried a few things, e.g. adding the user “raspotify” to the group pulse-access. This stopped the error messages for raspotify, although it is still not working.

But I think I might have pinned down the problem: I had installed alsa-utils previous to raspotify to force audio over the headphone jack (where my speakers are connected).

Removing alsa-utils lets me play Spotify via HDMI and the TV… Do you have any ideas how to force the audio output over the headphone jacks? The OSMC setting does not affect raspotify…

Any help is appreciated.

edit: Being brutal and putting hdmi_ignore_edid_audio=1 into /boot/config.txt seems to be quite nasty and raspotify stops doing anything/shows several errors. So that’s neither a simple and definitely not an elegant solution. :wink:

which device do you use for hifiberry?
raspotify is running, but no sound via hifiberry.

@MelBourbon, @Raspingtiao, @zilexa: For me it was working also just fine according to the HowTwo. Anyways, it stoped working, and I had same problem as you had. I reinstalled it and skipped changing the bitrate to 320 => Stays 160 then, and suddenly it works again. No idea why. Maybe someone else knows.

Hello, has anybody else the problem to get no sound out of the speakers when a2dp is installed. Connecting works fine. When I deinstall the a2dp package everything is working fine again. I tried on Vero4k and rpi3 with the same behavior. I think it is configuration but don‘t know how to. Has anyone an idea??


@zilexa : exactly the same problem as @chelvistero for me : connecting works fine and I can choose the OSMC device through my smartphone Spotify app. But no sound (I use speakers and a Justboom AMP sound card). No sound neither when I desactivate AMP sound and want to use TV speakers… Any help would be appreciated !