AirPlay / Spotify by Snapcast

  • Hello Thanks for the great work.

    For some reason Librespot is not playing on any of my snapclients.. I have test all clients using mopidy server and they do work.. So its not my snapclients..

    My snapserver seems to be working as i see when i start it, my clients receive data..

    Librespot works as i can use it to stream music from my phone to libreelec.. It seems that (after digging) Librespot is not piping audio to the sink file...

    snapclient log:

    snapserver log:

    Please let me know if you need any further logs etc.

  • Hi,

    I have just moved from OSMC to LibreELEC to take advantage of my Raspberry Pi 4 and was very excited to see that there is an easy way to cast Kodi output through Snapcast.

    However, after installing the addon, I do not see the PULSE: Snapserver device in the audio output selection box.

    [snip]

    I did a bit more digging and found that Pulseaudio could not start because of Bluetooth being disabled.

    After enabling it, I got pulseaudio starting.

    The device name in Kodi was still PULSE: Default Bluetooth, but selecting this made snapcast work just fine

    Edited once, last by ronan.l.n (June 3, 2020 at 8:37 PM).

  • Hello, I have a random question. MY current setup is Two Pi's, one running snapserver, and other running snapclient. All works perfectly! The snapserver is not connected to a TV/Screen as i just use if for music for my outdoor area. In the add-on settings we have three sinks/streams - Airplay, Spotify, Kodi/default. now i have set my default sink/stream to be spotify as this is what i mainly use. but if i want to airplay something from my phone to snapserver i need to set the add-on to stream this rather than Spotify. Is there a way i can trigger snapserver to change the stream without having to connect the pi to a display?

    Thanks again for the amazing development here!!!

  • I am currently running the millhouse development version of Libreelec based on Kodi 19 Alpha

    is there a version of Snapserver which will run on this yet ?

    it appears to be failing because of the move to Python 3 in Kodi 19

    Rasp3Libre:~/.kodi/temp # grep -i python kodi.log

    2020-03-06 12:39:08.307 T:1338 INFO <general>: CAddonMgr::FindAddons: xbmc.python v3.0.0 installed

    2020-03-06 12:39:12.561 T:1365 INFO <general>: initializing python engine.

    File "/usr/lib/python3.7/request.py", line 1319, in do_open

    File "/usr/lib/python3.7/client.py", line 1252, in request

    File "/usr/lib/python3.7/client.py", line 1298, in _send_request

    File "/usr/lib/python3.7/client.py", line 1247, in endheaders

    File "/usr/lib/python3.7/client.py", line 1026, in _send_output

    File "/usr/lib/python3.7/client.py", line 966, in send

    File "/usr/lib/python3.7/client.py", line 1422, in connect

    File "/usr/lib/python3.7/ssl.py", line 423, in wrap_socket

    File "/usr/lib/python3.7/ssl.py", line 870, in _create

    File "/usr/lib/python3.7/ssl.py", line 1139, in do_handshake

    File "/usr/lib/python3.7/request.py", line 222, in urlopen

    File "/usr/lib/python3.7/request.py", line 525, in open

    File "/usr/lib/python3.7/request.py", line 543, in _open

    File "/usr/lib/python3.7/request.py", line 503, in _call_chain

    File "/usr/lib/python3.7/request.py", line 1362, in https_open

    File "/usr/lib/python3.7/request.py", line 1321, in do_open

    File "/usr/lib/python3.7/__init__.py", line 341, in loads

    2020-07-13 13:12:02.265 T:1357 ERROR <general>: CAddonInstallJob[service.snapserver]: The dependency on xbmc.python version 2.1.0 could not be satisfied.

    2020-07-13 13:12:18.234 T:1358 ERROR <general>: CAddonInstallJob[service.snapserver]: The dependency on xbmc.python version 2.1.0 could not be satisfied.

    2020-07-13 13:12:26.799 T:1357 ERROR <general>: CAddonInstallJob[service.snapserver]: The dependency on xbmc.python version 2.1.0 could not be satisfied.

  • Hi There,

    Question after installing SnapServer addon on LibreELEC (official): 9.2.1 (RPi4.arm), and after rebooting, I then go to system audio settings; However the additional pulse audio output option that is added is "Pulse Audio: Null, Null, ......"

    I selected it anyway as the audio output device; installed snap client on my android (which notices the snap server on my pi right away) play a video on my pi; the onscreen video freezes immediately; no sound (or anything) on my android phone.

    What I'd love to do is hook up wifi headphones (e.g. audio only via wifi from my pi to my android).

    Any thoughts on what I should do next @awiouy

  • hello,

    If I have LE box(arm) and RaspberryPi4 with Volumio, is it possible to stream sound from LE to Volumio using snapcast? This addon avaliable for both of them.

    I've installed snapcast to both devices, but don't know what to do next, could someone help?

  • First thanks for the addon!

    Is there any way to make kodi believe it is playing music while snapclient is in use? It would be neat if kodi would show a visualizer while playing music via snapclient :)

  • First off, thanks so much for your hard work!

    I have a similar issue to ronan.l.n above.

    Running Kodi 18.9.0

    and libreELEC 9.2.7

    on a raspberry pi3.

    I can install snapserver and snapclient as per snapcast: add streaming from kodi by awiouy · Pull Request #2597 · LibreELEC/LibreELEC.tv · GitHub.

    BUT when I go to try to find PULSE: Snapserver in Settings/System/Audio/Audio output device, it's not listed as one of the options. Weird thing is though, I've had it working once and available in the last 24 hours. It appeared, I selected it, then the system worked beautifully and my pi downstairs picked it up straightaway. After rebooting PULSE: Snapserver disappeared. Only PULSE:bluetooth is left, which doesn't appear to work.

    Any thoughts on getting PULSE: Snapserver in Settings/System/Audio/Audio output device? I tried disabling and reenabling bluetooth, but no joy.

    Any thoughts?

  • So I installed the Snapclient from the LibreElec Add-On repository, was excited that an official Add-On was there! However, it doesn't work. Audio doesn't play, and the service appears to keep bouncing on/off/on/off.

    Logging in via SSH, I find this error from the current STDOUT for the Snapclient bin.

    Code
    Controller::onException: Can't open hdmi:CARD=PCH,DEV=0 PCM device: Device or resource busy

    I selected the HDMI output (my receiver is hooked up to Kodi that way, wanted to play audio through it), which is what Kodi is set to use. How do I get Kodi/LibreElec to play nice and output audio? Should I go and install PulseAudio add-on or what not?

    I'm Linux savvy, but unfamiliar with the specifics of how LibreElec/Kodi runs things under the hood, only ever used it as a media player/front end.

  • I am experiencing the same issues Stonster and grire974 seem to be having.

    On RPI4 (LibreElec 10.0.2), Snapserver does not work.
    Sometimes "Pulse Audio: Null, Null" does appear, at first install of the addon there was "Pulse Audio: Snapserver" but it's gone now, so I tried "Puls Audio: Bluetooth" (that works on another LibreElec I am running on a laptop).

    Whenever Snapserver is installed, audio and video don't work properly (after rebooting), songs don't play right, they stop at 0:00 or 0:02. This happens even when I switch system->audio output to my USB DAC back again. After uninstalling Snapserver, everything works fine, again.

    Has anyone got this working on RPI4?
    awiouy Do you have any idea what might be the problem?

  • Snapcast not releasing audio device back to KOdi when Kodi starts playing. another plugin needs to play audio . The sound is silent (snapcast not sending audio) - but the plugin can't play any audio

    I had an issue today where my daughter tried to put on a show from YouTube and there was no sound. I had just installd Snapcast client and music was playing from my snapcast server (which is on an Ubuntu KVM on my home server)


    BUT the switch to stop playing when a kodi plays was set to true.

    The music stopped but the YouTube player couldn't provide audio.
    The only way I've got it to work reliably was to go into settings and disable snapclient.

    Is there anything I can do to make sure that the audio will come through from other plugins?

    (I also put a separate post about setting snapclient latency settings to a finer degree - sorry Ididn't put it in this thread)

    Edited once, last by AllanK (November 5, 2022 at 2:35 PM).

  • Ok

    Thanks awiouy for this awesome addon.


    I've sorted this out, I'm leaving my solution for reference BUT also a request first (based on the solution to make it easier for others)

    Here's the feature request first

    1. Please allow selecting of player option .. (e.g. choose between ALSA and pulse , and probably pipewire at some point)
    I needed to edit service snapclient.service to replace the term snapclient with "snapclient --player pulse"

    Then when a particular player has been selected, list soundcards according to the player. (see step 3 of my solution)

    Here's the solution ..

    The problem - plugins not able to play audio if snapclient had been playing music.. (even if stopped at the time)

    Summary - move to pulse as audio "backend"/abstraction layer to prevent locking of the audio device..

    (My experience with Pulse is usually disable it as much as possible as I do professional mixing and mastering, but here, it's really come in handy).

    Configs

    1. autostart.sh to ensure the correct sinks are available and some other settings (to allow ac3 passthrough to my receiver)


    Pretty sure lines 1 and 2 are redundant - but anyway.. it's working
    As for the last line, as I don't use the "default" device in my config, so that is probably also not needed.

    2. Edit

    /storage/.kodi/addons/service.snapclient/bin/snapclient.start

    Change the invocation of snapclient to include --player pulse

    To


    3. Identify correct output (as the GUI still only displays ALSA outputs)

    LivingRoom:~/.kodi/addons/service.snapclient/bin # snapclient --player pulse --list

    4: default

    Let PulseAudio server choose the device

    1: just_a_sink_1

    Null Output

    2: alsa_output.pci-0000_00_01.1.hdmi-stereo

    Built-in Audio Digital Stereo (HDMI)

    3: alsa_output.pci-0000_00_14.2.iec958-stereo

    Built-in Audio Digital Stereo (IEC958)

    In this case my choice is 2, which is in the first line of the config file

    /storage/.kodi/userdata/addon_data/service.snapclient/settings.xml


    4. Make sure that Kodi is also using the same Pulse Audio device.. I did this via the GUI.. but this is from the guisettings.xml

    Code
    <setting id="audiooutput.audiodevice">PULSE:alsa_output.pci-0000_00_01.1.hdmi-stereo</setting>


    I was able to switch between

    Movie played by Kodi (AC3 passthrough)
    Music played by Kodi (PCM stereo)
    Video played by the youtube addon (PCM stereo)

    My snapserver (fed by Mopidy) was sending music the whole time and it was being played out to the speakers via my receiver connected via HDMI.

    Everything played nicely for everything and the music popped up in between ..

    Looking forward to the summer BBQ season.. and if the kids decide to watch a movie when the evening hits, they can do that and all the other speakers in the house will keep playing to the party.

    For reference sake - the is on the generic amd64 build

    The CPU I tested with is
    AMD A10-7860K Radeon R7, 12 Compute Cores 4C+8G

    I have the 2 core version and will test this configuration on that too (although not using HDMI for audio, but spdif, and to a 2.1 system)

    Hopefully later I'll also be able to test against an unoficial Rockchip build (ordered for another entertaining area), a device I'll be running headless, so that should be interesting..

    Edited once, last by AllanK (November 6, 2022 at 3:01 PM).

  • Addendum -

    For autostart.sh.. to get the correct sink and card issue the following ..

    pactl list cards

    The output will look something like this

    Code
    Card #0
        Name: alsa_card.pci-0000_00_01.1
        Driver: module-alsa-card.c
        Owner Module: 17
        Properties:
            alsa.card = "0"
            alsa.card_name = "HDA ATI HDMI"
            alsa.long_card_name = "HDA ATI HDMI at 0xfeb64000 irq 48"
            alsa.driver_name = "snd_hda_intel"

    giving the 0 for this line in the autostart.sh

    pactl set-card-profile 0 output:hdmi-stereo

    and then

    pactl list sinks short


    which outputs something like this

    Code
    1    just_a_sink_1    module-null-sink.c    s16le 2ch 44100Hz    SUSPENDED
    2    alsa_output.pci-0000_00_01.1.hdmi-stereo    module-alsa-card.c    s16le 2ch 48000Hz    SUSPENDED
    3    alsa_output.pci-0000_00_14.2.iec958-stereo    module-alsa-card.c    s16le 2ch 44100Hz    SUSPENDED

    That gave me the 2 for this line in autostart.sh

    pactl set-sink-formats 2 "pcm; ac3-iec61937; dts-iec61937; eac3-iec61937"

    Hope this helps someone else sort this out.

  • These instructions worked on my RPi3B+ too.

    I had been having issues where if the system was not shut down nicely, i.e the power was cut then the audio didn't recover.

    Using your autostart.sh fixed all this.

    Thank you.

  • Hi,

    I've been trying to set a Libreelec media server as:

    - host-1 ("salon"): rpi4 running libreelec with the snapserver and librespot addons, setup to stream spotify, and the snapclient addon setup to listen to the snapserver.

    - host-2 ("sam"): rpi4 running raspbian with a snapclient setup to listen to the snapserver

    I managed to get the librespot@host-1 visible in spotify and to stream to libreelec flawlessly. I even get the visualisation of the album cover as i plays in libreelec. Neat.

    However, the host-2 snapclient is not receiving any data from the server.

    By investigating, I see in snapweb (the icons are broken ?) both snapclients as expected, but the stream is 'default: idle', and not responding. Changing the volume/muting is not doing anything. So it seems neither clients are not receiving any data

    What am I doing wrong ? How can host-1 play the stream is no data is transfered through the snapserver ?

    Can somebody help me set this up correctly ?

    Regards,

    EDIT: found out the issue.``

    /storage/.kodi/addons/service.snapserver/bin/snapserver.start` was using --stream instead of --stream.source

    Am I the only one experiencing this issue ? Should I create a pull request with that fix ?

  • I have been messing around to get the snapserver to get it to work the way I want. I got it to play to all streams kodi, spotify, and airplay at the same time, which @Mr.Tiptop you asked about. I get it to also play the kodi audio out to the hdmi output and send it to snapserver.


    To do this I edited the /storage/.kodi/addons/service.snapserver/bin/snapserver.start file.


    I added this line to combine the Snapserver audio sink and the sink that outputs the audio to hdmi. Allowing audio to be streamed from kodi and play out to hdmi. You can look @AllanK guide right above to get the alsa_output.1.hdmi-stereo sink.

    Code
    pactl load-module module-combine-sink sink_name=combined_sink_name slaves=Snapserver,alsa_output.1.hdmi-stereo


    I then removed all the if statements and made the each stream its own variable to add to the server separately.

    Code
    stream0="pipe://$file?name=Kodi"
    stream1="spotify:///librespot?name=Spotify&devicename=$ss_ln"
    #stream="$stream&params=--zeroconf-port%3D$ss_lp"
    stream2="airplay:///shairport-sync?name=AirPlay"

    Then I just add --stream.stream for each stream source.