librespot-org / librespot

Open Source Spotify client library
MIT License
4.52k stars 544 forks source link

Playback stops when playlist ends #1170

Closed rwjack closed 1 year ago

rwjack commented 1 year ago

Describe the bug It's almost as if this option (screenshot from spotify client) doesn't exist in librespot image

Host (what you are running librespot on):

Add env

ENV LANG C.UTF-8

RUN \ apk add --no-cache --virtual .build-dependencies \ build-base=0.5-r3 \ cargo=1.60.0-r2 \ git \ protobuf-dev=3.18.1-r3 \ pulseaudio-dev=15.0-r2 \ \ && apk add --no-cache \ pulseaudio=15.0-r2 \ \ && cargo install \ --locked \ --no-default-features \ --features pulseaudio-backend \ --root /usr \ --bin librespot \ --version 0.4.2 \ --verbose \ -- librespot \ \ && apk del --no-cache --purge .build-dependencies \ && rm -fr \ /tmp/* \ ~/.cargo \ /usr/.crates.toml \ /usr/.crates2.json

Install snapcast

RUN sed -i -e 's/v[[:digit:]]..*\//edge\//g' /etc/apk/repositories && apk add --no-cache snapcast bash

Copy data for add-on

COPY run.sh / RUN chmod a+x /run.sh

CMD [ "/run.sh" ]

eladyn commented 1 year ago

This might be the same issue as https://github.com/librespot-org/librespot/issues/1046.

rwjack commented 1 year ago

Interesting. I sure would like to try out the dev branch, but I have no idea how to modify this Dockerfile in order to do so.

eladyn commented 1 year ago

Oh, didn't notice that you are on 0.4.2. At this point, the autoplay option in the official client indeed doesn't affect librespot, and you need to turn --autoplay on manually.

kingosticks commented 1 year ago

Interesting. I sure would like to try out the dev branch, but I have no idea how to modify this Dockerfile in order to do so.

The top few Google hits sound pretty promising, maybe:

&& cargo install \
        --locked \
        --no-default-features \
        --features pulseaudio-backend \
        --root /usr \
        --bin librespot \
        --git https://github.com/librespot-org/librespot \
        --branch dev \
        --verbose \
        -- librespot \
rwjack commented 1 year ago

I'm building my container to start librespot with the --autoplay on flag. Let me see how it works

rwjack commented 1 year ago

And it did not seem to work...

It's Snapserver that actually starts up librespot, and here are the relevant log lines:

2023-06-01 13-46-44.492 [Info] (Snapserver) Version 0.27.0
2023-06-01 13-46-44.492 [Info] (Snapserver) Adding stream: spotify:///librespot?name=Spotify&username=xxx&password=xxx&devicename=HA_Snapcast&bitrate=320&volume=100&autoplay=on
2023-06-01 13-46-44.492 [Info] (Snapserver) Adding stream: tcp://0.0.0.0:4953?name=TTS&mode=server
2023-06-01 13-46-44.492 [Notice] (init) Settings file: "/data/snapserver/server.json"
2023-06-01 13-46-44.492 [Info] (Snapserver) Using HTTP host name: local-snapcast-server-libspot
2023-06-01 13-46-44.492 [Error] (Avahi) Failed to create client: Daemon not running
2023-06-01 13-46-44.492 [Info] (PcmStream) PcmStream: Spotify, sampleFormat: 44100:16:2
2023-06-01 13-46-44.493 [Info] (Server) Stream: {"fragment":"","host":"","path":"/librespot","query":{"autoplay":"on","bitrate":"320","chunk_ms":"20","codec":"flac","devicename":"HA_Snapcast","name":"Spotify","password":"xxx","sampleformat":"44100:16:2","username":"xxx","volume":"100"},"raw":"spotify:////librespot?autoplay=on&bitrate=320&chunk_ms=20&codec=flac&devicename=HA_Snapcast&name=Spotify&password=xxx&sampleformat=44100:16:2&username=xxx&volume=100","scheme":"spotify"}

Looking at the processes in the container, the autoplay flag isn't there. (omitted --username and -password) image

This is probably a question for the Snapcast repo, but curious if anyone has encountered something similar.

eladyn commented 1 year ago

@rwjack Indeed, that probably doesn't belong here then, but snapcast expects true instead of on for the autoplay option.

rwjack commented 1 year ago

Well damn, you got me confused here:

Oh, didn't notice that you are on 0.4.2. At this point, the autoplay option in the official client indeed doesn't affect librespot, and you need to turn --autoplay on manually.

Yeah, upon setting autoplay=true in the Snapcast config, now I see the command line flag --autoplay on

roderickvd commented 1 year ago

Pretty sure this is not a librespot bug, so closing, but feel free to continue the discussion here or on Gitter.