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

#83

recently raspotify was not working for me so i tried to reinstall it. and i get:

dpkg error
" package architecture (armhf) does not match system (amd64)
"

i’m pretty sure i didn’t change architecture

“root@debian:/home/duuri# uname -a
Linux debian 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u4 (2018-08-21) x86_64 GNU/Linux”

0 Likes

#84

Looks like PC with Debian installed, not OSMC machine.

0 Likes

#85

omg my bad. i didn’t notice i got disconnected from my vpn :frowning:

0 Likes

#86

Just discovered this project after reinstalling my OSMC, I want to use it to play music on spotify instead of my Echo Dot. Everything goes great, It plays songs but via the 3,5mm jack and not HDMI. Used the ```

aplay -l command:
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/7
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0

Chose the --device hw:0,1 but still nothing. The music stored in the external drive plays via HDMI.

0 Likes

#87

I stopped using Vero4K with Spotify. It is simply not stable, sometimes need to reboot the device to see it appear in Spotify on my phone. It is also extremely annoying you cannot stop the playback in OSMC to watch something. It’s been over a year and there is no priority to add Spotify Connect to OSMC officially, even after lots of requests.

I can no longer recommend this method of manually installing it, only for experimental purposes since it is not well integrated and does not give you the simple install once and use forever experience.

I am switching soon to using the Vero4K purely Al’s a playback device for video and absolutely nothing else, even though it has plenty of resources to do more… Not sure if the future will bring more, but the waiting is over for me.

0 Likes

#88

All that an official integration would feature is what’s available here, but via a one click installation.

If it is not stable, then we need to improve that first before including it.

What are some of the problems you have experienced and do you have any previous posts about this so I can look in to it?

Sam

1 Like

#89

It works fine here. I use Spotify on my Vero4k at least 2-3 hours every day for the last 6 months or so. I very rarely have any trouble connecting. Certainly no more than on my Cambridge StreamMagic which is an ‘official’ Spotify device. I usually have the Apple Aerial screensaver running on OSMC at the same time to have some visuals with my music …

0 Likes

#91

This works as a charm on my Raspberry Pi 3 + Hifiberry DAC+ setup. I only had to

  • select the DAC+: OPTIONS="--device hw:0", and for some reason
  • explicitly choose backend:BACKEND_ARGS="--backend alsa"

I used to use AirPlay for audio which worked excellent but killed the iOS device battery. The only caveat is of course that the service still isn’t playing nice with Kodi/OSMC.

Has anyone tried to solve this?

0 Likes

#92

Hi,

I have Osmc 18.2 latest beta on a Rpi2, and Hifiberry DAC+. I have installed raspotify, and my issue that I want to solve was the same with previous builds of OSMC as well, so it is not related to latest beta.

I would like to listen to audio through Hifiberry DAC+. This worked like charm with OSMC w/o raspotify. When I installed raspotify, I changed config.txt and added dtoverlay=hifiberry-dacplus. I also created /etc/asound.conf with following entry:
pcm.!default {
 type hw card 0
}
ctl.!default {
 type hw card 0
}

Finally, in /etc/default/raspotify the only entries are:
BITRATE=“320”
OPTIONS="–device hw:1"

With these settings raspotify works with my Hifiberry DAC+. But Kodi does not find Hifiberry anymore, in settings it shows only an Alsa device that refers to the internal audio (?). HDMI audio works, though.

If I just add the following to config.txt:
dtoverlay=hifiberry-dacplus
dtparam=audio=off

it is the other way round, Kodi can find the Hifiberry DAC+, but raspotify produces no audio through the DAC+.

osmc@osmc-Mortimer:~$ aplay -l
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: sndrpihifiberry [snd_rpi_hifiberry_dacplus], Gerät 0: HiFiBerry DAC+ HiFi pcm512x-hifi-0 []
Sub-Geräte: 0/1
Sub-Gerät #0: subdevice #0

Is there any solution to use DAC+ with both Kodi and raspotify? Thanks!

Eriol

0 Likes

#93

I’m also using raspotify and Hifiberry DAC+ and it works like a charm.

I have this in my config.txt:
dtoverlay=hifiberry-dacplus-overlay

0 Likes

#94

Ok, sometimes it is wise to do things step by step and if stuck follow the golden rule: “Never change more than one thing …”

Normally, in my configuration the internal audio is card #0 and the HiFiBerry DAC+ is card #1.

dtparam=audio=off turns the internal audio system off. Sound over HDMI of course still works, but the 3.5mm audio jack doesn’t. Consequently, now HiFiBerry DAC+ is card #0.

Therefore, the ALSA and raspotify config files of course need to be modified to fit to the current setting. In my case, as I am not using the internal audio it is best to switch it off, and then of course link ALSA and raspotify to card #0 (HiFiBerry).

This works very well - I now can listen to HiFi audio without switching my TV set on, with Kodi and Yatse or with Spotify and raspotify. And if I watch a movie with Kodi, I just change the output to the 5.1 sound system via HDMI. This indeed works like charme.

I am summarizing this here because others might be in a similar situation trying to get both systems running in parallel. It would be great to have raspotify integrated into Kodi, because Spotify Connect does not really work very well.

Cheers,
Eriol

1 Like

#95

I have been using this for about a week now! I’m really happy with it.

  • Connection via HDMI is 100% preferable over Bluetooth (for me) especially when using it with multiple people: everyone can take over at any point and leaving the house keeps the music going for the others;
  • I can go wherever in the house without losing connection;
  • The sound quality is very good;
  • Lastly, it should result in better phone battery life since the downloading&playing is done completely by OSMC (vero 4k in my case), not by the phone - not that I’ve noticed it personally but that’s just my reasoning.

It has been very stable during the first days of using this, only today (after a week) I encountered a few random disconnects. All I needed to do was restart the service (sudo systemctl restart raspotify), wait a few seconds and all was good.

I don’t know what caused it, but it may have been something on the Kodi end (trying to play audio?). It could also have been a client on a laptop that tried taking back playback. I really don’t know. Hoping that this gets better and better, this is definitely the preferred way to go for me.

Sorry - there’s no real point to this post other than to express my appreciation and say a big THANKS to @zilexa and the devs of the two(?) packages because it’s awesome (in potential), and to say that I have mostly had really good results.

0 Likes

#96

What config.txt is this, if I may ask, @ratelutz ?

0 Likes

#97

/boot/config.txt which is the bare metal config file for the RaspberryPie

1 Like

#98

thanks fzinken for answering. i didn’t check the forum for some time

0 Likes

#99

Hi, I have problem with playback. VERO 4k+ on SPDIF audio output.

root@osmc:~# service raspotify status
* raspotify.service - Raspotify
   Loaded: loaded (/lib/systemd/system/raspotify.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-04-19 11:20:47 CEST; 13s ago
  Process: 7188 ExecStartPre=/bin/chown raspotify:raspotify /var/cache/raspotify (code=exited, status=0/SUCCESS)
  Process: 7187 ExecStartPre=/bin/mkdir -m 0755 -p /var/cache/raspotify (code=exited, status=0/SUCCESS)
 Main PID: 7193 (librespot)
   CGroup: /system.slice/raspotify.service
           `-7193 /usr/bin/librespot --name OSMC-SPOTIFY --backend alsa --bitrate 160 --disable-audio-cache --enable-volume-normalisation --linear-volume --initial-volume=100 --device hw:0

Apr 19 11:20:55 osmc librespot[7193]: INFO:librespot_core::session: Connecting to AP "gew1-accesspoint-b-7scv.ap.spotify.com:4070"
Apr 19 11:20:55 osmc librespot[7193]: INFO:librespot_core::session: Authenticated as "11171064570" !
Apr 19 11:20:55 osmc librespot[7193]: INFO:librespot_playback::audio_backend::alsa: Using alsa sink
Apr 19 11:20:55 osmc librespot[7193]: INFO:librespot_core::session: Country: "CZ"
Apr 19 11:20:55 osmc librespot[7193]: INFO:librespot_playback::player: Loading track "Lost & Found" with Spotify URI "spotify:track:7AlQFgEIEBNsud8HOacONj"
Apr 19 11:20:56 osmc librespot[7193]: INFO:librespot_playback::player: Track "Lost & Found" loaded
Apr 19 11:20:57 osmc librespot[7193]: ERROR:librespot_playback::audio_backend::alsa: Alsa error PCM open ALSA function 'snd_pcm_hw_params_set_buffer_size_near' failed with error 'EINVAL: Invalid argument'
Apr 19 11:20:57 osmc librespot[7193]: ERROR:librespot_playback::player: Could not start audio: Alsa error: PCM open failed
Apr 19 11:20:57 osmc librespot[7193]: ERROR:librespot_playback::audio_backend::alsa: Alsa error PCM open ALSA function 'snd_pcm_hw_params_set_buffer_size_near' failed with error 'EINVAL: Invalid argument'
Apr 19 11:20:57 osmc librespot[7193]: ERROR:librespot_playback::player: Could not start audio: Alsa error: PCM open failed

RASPOTIFY CONF

` Device name on Spotify Connect`
        DEVICE_NAME="OSMC-SPOTIFY"

        # Bitrate, one of 96 (low quality), 160 (default quality), or 320 (high quality)
        BITRATE="160"

        # Additional command line arguments for librespot can be set below.
        # See `librespot -h` for more info. Make sure whatever arguments you specify
        # aren't already covered by other variables in this file. (See the daemon's
        # config at `/lib/systemd/system/raspotify.service` for more technical details.)
        #
        # To make your device visible on Spotify Connect across the Internet add your
        # username and password which can be set via "Set device password", on your
        # account settings, use `--username` and `--password`.
        #
        # 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.
        #
        #OPTIONS="--username <xxxxxxx> --password <xxxxxx>"

        OPTIONS="--device hw:0"

        # Uncomment to use a cache for downloaded audio files. Cache is disabled by
        # default. It's best to leave this as-is if you want to use it, since
        # permissions are properly set on the directory `/var/cache/raspotify'.
        #CACHE_ARGS="--cache /var/cache/raspotify"

        # By default, the volume normalization is enabled, add alternative volume
        # arguments here if you'd like, but these should be fine.
        #VOLUME_ARGS="--enable-volume-normalisation --linear-volume --initial-volume=100"

        # Backend could be set to pipe here, but it's for very advanced use cases of
        # librespot, so you shouldn't need to change this under normal circumstances.
        #BACKEND_ARGS="--backend pipe"
0 Likes

#100

From above, it looks like changing the bitrate can help here.

0 Likes

#101

Nah, I tried all kinds of bitrate in raspotify.conf, still same error. :frowning:

Can anyone help?

0 Likes

#102

Just so you know, your login details are in the config file. Better change your password…

1 Like

#103

Thanks, will do. But still no idea what’s the issue here with the

ERROR:librespot_playback::audio_backend::alsa: Alsa error PCM open ALSA function 'snd_pcm_hw_params_set_buffer_size_near' failed with error 'EINVAL: Invalid argument'
Apr 19 11:20:57 osmc librespot[7193]: ERROR:librespot_playback::player: Could not start audio: Alsa error: PCM open failed
0 Likes