[GH-ISSUE #1550] Confusing shuffle behaviour #700

Closed
opened 2026-02-27 19:32:02 +03:00 by kerem · 5 comments
Owner

Originally created by @aome510 on GitHub (Aug 24, 2025).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1550

Before all, I want to say thank you for releasing a new librespot version. I've been waiting for the new release since people reported getting different issues when they used my project with Spotify breaking their APIs 🤦.

Back to the issue, I recently upgraded librespot to 0.7.0 for my spotify-player project and found the new shuffle behaviour confusing.

It seems librespot doesn't allow shuffle when the repeat is either track or context. Receiving

ERROR librespot_connect::spirc: failed to handle request: Service unavailable { currently shuffle is not allowed because endless_context }

every time I use Spotify API to change the shuffle state. It only works with the repeat mode is off. I found the code responsible for this check in

github.com/photovoltex/librespot@78ce118d32/connect/src/state/restrictions.rs (L55)

My main question is why do we disallow shuffle when the repeat mode is not off?

The confusing part is that the shuffle state is still updated even when the message said otherwise. For example, if I set the shuffle to true when repeat is context, it will first show shuffle to be false with the above error message but when the next song is played, the shuffle state is updated to true.

I'm guessing this happens because we set the state before handling the state change in github.com/photovoltex/librespot@78ce118d32/connect/src/state/handle.rs (L13-L17)

self.shuffle is when the Service unavailable error is returned.

Originally created by @aome510 on GitHub (Aug 24, 2025). Original GitHub issue: https://github.com/librespot-org/librespot/issues/1550 Before all, I want to say thank you for releasing a new librespot version. I've been waiting for the new release since people reported getting different issues when they used my project with Spotify breaking their APIs 🤦. Back to the issue, I recently upgraded `librespot` to `0.7.0` for my [`spotify-player` project](https://github.com/aome510/spotify-player) and found the new shuffle behaviour confusing. It seems `librespot` doesn't allow shuffle when the repeat is either `track` or `context`. Receiving ``` ERROR librespot_connect::spirc: failed to handle request: Service unavailable { currently shuffle is not allowed because endless_context } ``` every time I use Spotify API to change the shuffle state. It only works with the repeat mode is `off`. I found the code responsible for this check in https://github.com/photovoltex/librespot/blob/78ce118d32912adfb2705481f69c83df6a88211f/connect/src/state/restrictions.rs#L55 My main question is **why do we disallow shuffle when the repeat mode is not off?** The confusing part is that the shuffle state is still updated even when the message said otherwise. For example, if I set the shuffle to true when repeat is context, it will first show shuffle to be false with the above error message but when the next song is played, the shuffle state is updated to true. I'm guessing this happens because we set the state before handling the state change in https://github.com/photovoltex/librespot/blob/78ce118d32912adfb2705481f69c83df6a88211f/connect/src/state/handle.rs#L13-L17 `self.shuffle` is when the `Service unavailable` error is returned.
kerem closed this issue 2026-02-27 19:32:02 +03:00
Author
Owner

@photovoltex commented on GitHub (Aug 25, 2025):

Track repeat and shuffle seems a bit silly so let's talk about context repeat and shuffle.

I can't tell for certain anymore why we changed it like that but I remember spotify did behave similar at the time. But currently it seems they have changed it or never did so before? Hard to tell but most of the implementation tries to copy spotifys behavior.

It might also be a limitation of the state back then that wasn't adjusted so we could changed that again but this will probably need some adjustment in code for context repeat as the shuffle context and context are not the same.

<!-- gh-comment-id:3218987706 --> @photovoltex commented on GitHub (Aug 25, 2025): Track repeat and shuffle seems a bit silly so let's talk about context repeat and shuffle. I can't tell for certain anymore why we changed it like that but I remember spotify did behave similar at the time. But currently it seems they have changed it or never did so before? Hard to tell but most of the implementation tries to copy spotifys behavior. It might also be a limitation of the state back then that wasn't adjusted so we could changed that again but this will probably need some adjustment in code for context repeat as the shuffle context and context are not the same.
Author
Owner

@aome510 commented on GitHub (Aug 25, 2025):

Track repeat and shuffle seems a bit silly

yeah I agree but that doesn't mean we shouldn't allow to set the state accordingly. I believe Spotify does support all the state combination of shuffle/repeat

<!-- gh-comment-id:3220470468 --> @aome510 commented on GitHub (Aug 25, 2025): > Track repeat and shuffle seems a bit silly yeah I agree but that doesn't mean we shouldn't allow to set the state accordingly. I believe Spotify does support **all** the state combination of shuffle/repeat
Author
Owner

@photovoltex commented on GitHub (Aug 26, 2025):

I think will take a look what the overhead of the change would be, in theory it shouldn't be to bad. If so, I suppose we could remove the restriction or adjust it accordingly if spotify now a days allows the combination.

<!-- gh-comment-id:3223499551 --> @photovoltex commented on GitHub (Aug 26, 2025): I think will take a look what the overhead of the change would be, in theory it shouldn't be to bad. If so, I suppose we could remove the restriction or adjust it accordingly if spotify now a days allows the combination.
Author
Owner

@photovoltex commented on GitHub (Aug 28, 2025):

So I made some progress here but there are still some inconsistent behavior when toggling repeat on and off. When I have fixed them I will create a PR for it.

The behavior between shuffle and repeat will be that the shuffled context will be repeated, but not be reshuffled. That's apparently what spotify does currently and that's what we aim for.

<!-- gh-comment-id:3233422478 --> @photovoltex commented on GitHub (Aug 28, 2025): So I made some progress [here](https://github.com/photovoltex/librespot/tree/adjust/shuffle-repeat-interaction) but there are still some inconsistent behavior when toggling repeat on and off. When I have fixed them I will create a PR for it. The behavior between shuffle and repeat will be that the shuffled context will be repeated, but not be reshuffled. That's apparently what spotify does currently and that's what we aim for.
Author
Owner

@aome510 commented on GitHub (Aug 28, 2025):

So I made some progress here but there are still some inconsistent behavior when toggling repeat on and off. When I have fixed them I will create a PR for it.

The behavior between shuffle and repeat will be that the shuffled context will be repeated, but not be reshuffled. That's apparently what spotify does currently and that's what we aim for.

amazing, thank you @photovoltex!

<!-- gh-comment-id:3233490888 --> @aome510 commented on GitHub (Aug 28, 2025): > So I made some progress [here](https://github.com/photovoltex/librespot/tree/adjust/shuffle-repeat-interaction) but there are still some inconsistent behavior when toggling repeat on and off. When I have fixed them I will create a PR for it. > > The behavior between shuffle and repeat will be that the shuffled context will be repeated, but not be reshuffled. That's apparently what spotify does currently and that's what we aim for. amazing, thank you @photovoltex!
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#700
No description provided.