Skip to content

Add a playback_ready field to the "/" api response#298

Merged
devgianlu merged 3 commits intodevgianlu:masterfrom
dubeyKartikay:add-player-ready
Apr 12, 2026
Merged

Add a playback_ready field to the "/" api response#298
devgianlu merged 3 commits intodevgianlu:masterfrom
dubeyKartikay:add-player-ready

Conversation

@dubeyKartikay
Copy link
Copy Markdown
Contributor

@dubeyKartikay dubeyKartikay commented Mar 23, 2026

While trying to test the /player/play endpoint. I ran into a bug where the app would say that "its up" ( GET "/" and "/status" would return 200) but when i hit the /player/play endpoint, the playback would fail.

sometimes the connection id was not set, sometimes the volume sync hadn't happened, which led to the volume of the track changing mid playback.

So i had to expose a playback_ready field that is set to true whenever its safe to call /player/play and false otherwise

fixup
@guidcruncher
Copy link
Copy Markdown

could this be emitted as a event toi?

@dubeyKartikay
Copy link
Copy Markdown
Contributor Author

Actually that's a great idea, I'll make the changes

@dubeyKartikay
Copy link
Copy Markdown
Contributor Author

Actually, after adding this, and testing for a bit.
i found out that emmiting this as an event is... finiky and not all that reliable.
Here's why :

  1. You probably just started go-librespot, that's why you need to know when its ready for playback
  2. To revieve the playback_ready event, you have to connect to the websocket before the event gets emmited. Otherwise youll miss it.

This kinda makes things unreliable.

@devgianlu what are your thoughts on this?

Copy link
Copy Markdown
Owner

@devgianlu devgianlu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the suggested changes the PR should be smaller.

The WS event can stay, it doesn't hurt and can still be useful if the initial connect state PUT takes a while. You can always check via the API and then wait for the event to avoid polling.

Comment thread cmd/daemon/api_server.go Outdated
Comment thread cmd/daemon/main.go Outdated
Comment thread cmd/daemon/player.go Outdated
@devgianlu devgianlu merged commit 1e3a53b into devgianlu:master Apr 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants