[GH-ISSUE #294] Implement 'autoplay' functionality #197

Closed
opened 2026-02-27 19:29:22 +03:00 by kerem · 14 comments
Owner

Originally created by @mordax7 on GitHub (Mar 2, 2019).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/294

Sometimes if I let Spotify run for a long time period I come to the end of my playlist, especially if it's really short. Therefore I have in my Spotify Desktop Client the option enabled to play similar songs on the end of the playlist.
screenshot-20190302150052-931x113

I noticed this was not working when using librespot, would it be possible to implement this?

Regards.

Originally created by @mordax7 on GitHub (Mar 2, 2019). Original GitHub issue: https://github.com/librespot-org/librespot/issues/294 Sometimes if I let Spotify run for a long time period I come to the end of my playlist, especially if it's really short. Therefore I have in my Spotify Desktop Client the option enabled to play similar songs on the end of the playlist. ![screenshot-20190302150052-931x113](https://user-images.githubusercontent.com/27705384/53683007-1435b500-3cfc-11e9-99ff-1162a3fcb01a.png) I noticed this was not working when using librespot, would it be possible to implement this? Regards.
kerem 2026-02-27 19:29:22 +03:00
Author
Owner

@devgianlu commented on GitHub (Mar 2, 2019):

This doesn't seem to be communicated to the player, so it'll have to be an option inside librespot. I suppose you need to turn off repeat in order for this to work. Right?

<!-- gh-comment-id:468923843 --> @devgianlu commented on GitHub (Mar 2, 2019): This doesn't seem to be communicated to the player, so it'll have to be an option inside `librespot`. I suppose you need to turn off repeat in order for this to work. Right?
Author
Owner

@mordax7 commented on GitHub (Mar 2, 2019):

Exactly, repeat has to be disabled this to work.

<!-- gh-comment-id:468924568 --> @mordax7 commented on GitHub (Mar 2, 2019): Exactly, repeat has to be disabled this to work.
Author
Owner

@devgianlu commented on GitHub (Mar 2, 2019):

Stole the idea and implemented it in librespot-java!

<!-- gh-comment-id:468930500 --> @devgianlu commented on GitHub (Mar 2, 2019): Stole the idea and implemented it in `librespot-java`!
Author
Owner

@sashahilton00 commented on GitHub (Mar 11, 2019):

@devgianlu was there any reverse engineering required, or are you just pulling the queue again once the local queue ends?

<!-- gh-comment-id:471694443 --> @sashahilton00 commented on GitHub (Mar 11, 2019): @devgianlu was there any reverse engineering required, or are you just pulling the queue again once the local queue ends?
Author
Owner

@devgianlu commented on GitHub (Mar 11, 2019):

I am using the hm://radio-apollo/v3/stations/ endpoint to create a station for the given context and they I play it normally.

<!-- gh-comment-id:471697111 --> @devgianlu commented on GitHub (Mar 11, 2019): I am using the `hm://radio-apollo/v3/stations/` endpoint to create a station for the given context and they I play it normally.
Author
Owner

@ashthespy commented on GitHub (Mar 22, 2019):

FWIW: There is an endpoint for this, didn't look into it in detail though.
hm://autoplay-enabled/query

<!-- gh-comment-id:475669822 --> @ashthespy commented on GitHub (Mar 22, 2019): FWIW: There is an endpoint for this, didn't look into it in detail though. `hm://autoplay-enabled/query`
Author
Owner

@devgianlu commented on GitHub (Mar 23, 2019):

@ashthespy Is there anything more to it? Doing GET hm://autoplay-enabled/query returns 400.

<!-- gh-comment-id:475872555 --> @devgianlu commented on GitHub (Mar 23, 2019): @ashthespy Is there anything more to it? Doing `GET hm://autoplay-enabled/query` returns `400`.
Author
Owner

@ashthespy commented on GitHub (Mar 23, 2019):

@devgianlu Sorry, no I didn't have time to dump more packets and investigate. But it seems to follow the format of hm://autoplay-enabled/query?uri=spotify%3Auser%3A where the uri is of the current playlist.

<!-- gh-comment-id:475908074 --> @ashthespy commented on GitHub (Mar 23, 2019): @devgianlu Sorry, no I didn't have time to dump more packets and investigate. But it seems to follow the format of `hm://autoplay-enabled/query?uri=spotify%3Auser%3A` where the uri is of the current playlist.
Author
Owner

@sashahilton00 commented on GitHub (Mar 23, 2019):

@devgianlu @ashthespy it's pretty simple. You just send a request to the autoplay endpoint as follows:

hm://autoplay-enabled/query?uri=spotify:user:sashahilton00:playlist:5fFTfhV...jqkezuVT

You'll then get a response, which is just a URI to a station for that playlist:

spotify:station:user:sashahilton00:playlist:5fFTfhV...jqkezuVT

Use the normal endpoint to get the JSON payload for the station:

hm://radio-apollo/v3/stations/spotify:station:user:sashahilton00:playlist:5fFTfhV...jqkezuVT

Then you'll get a JSON payload, which can then just be played like a station normally is. Makes sense that it's a toggle in the client, since the only thing it does is wait for the queue to empty, then makes the above requests and starts playing the radio for the given playlist.

<!-- gh-comment-id:475911161 --> @sashahilton00 commented on GitHub (Mar 23, 2019): @devgianlu @ashthespy it's pretty simple. You just send a request to the autoplay endpoint as follows: `hm://autoplay-enabled/query?uri=spotify:user:sashahilton00:playlist:5fFTfhV...jqkezuVT` You'll then get a response, which is just a URI to a station for that playlist: `spotify:station:user:sashahilton00:playlist:5fFTfhV...jqkezuVT` Use the normal endpoint to get the JSON payload for the station: `hm://radio-apollo/v3/stations/spotify:station:user:sashahilton00:playlist:5fFTfhV...jqkezuVT` Then you'll get a JSON payload, which can then just be played like a station normally is. Makes sense that it's a toggle in the client, since the only thing it does is wait for the queue to empty, then makes the above requests and starts playing the radio for the given playlist.
Author
Owner

@devgianlu commented on GitHub (Mar 23, 2019):

My implementation is obsolete then. What if autoplay is disabled? Does it still make the request?

<!-- gh-comment-id:475911544 --> @devgianlu commented on GitHub (Mar 23, 2019): My implementation is obsolete then. What if autoplay is disabled? Does it still make the request?
Author
Owner

@sashahilton00 commented on GitHub (Mar 23, 2019):

Haven't checked, but given it's a client toggle, I imagine if it's disabled it doesn't, and just stops playing once playlist/album is finished

<!-- gh-comment-id:475911606 --> @sashahilton00 commented on GitHub (Mar 23, 2019): Haven't checked, but given it's a client toggle, I imagine if it's disabled it doesn't, and just stops playing once playlist/album is finished
Author
Owner

@devgianlu commented on GitHub (Mar 24, 2019):

Anyone tested this? I keep getting 204.

<!-- gh-comment-id:475950430 --> @devgianlu commented on GitHub (Mar 24, 2019): Anyone tested this? I keep getting `204`.
Author
Owner

@ashthespy commented on GitHub (Mar 24, 2019):

I have the same as @sashahilton00 - the endpoint responds with the station uri in plain old bytes.

<!-- gh-comment-id:475963420 --> @ashthespy commented on GitHub (Mar 24, 2019): I have the same as @sashahilton00 - the endpoint responds with the station `uri` in plain old bytes.
Author
Owner

@OrestTa commented on GitHub (Oct 19, 2019):

Any status updates on this one? (Such a feature would be amazing indeed!)

One possible workaround is of course to use something like shairport ( https://github.com/mikebrady/shairport-sync ) as, this way, the stream is managed by the user device (phone) and autoplay just works.

<!-- gh-comment-id:544124828 --> @OrestTa commented on GitHub (Oct 19, 2019): Any status updates on this one? (Such a feature would be amazing indeed!) One possible workaround is of course to use something like shairport ( https://github.com/mikebrady/shairport-sync ) as, this way, the stream is managed by the user device (phone) and autoplay just works.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#197
No description provided.