I'm building a queue system for a music player where I would like to be able to reorder songs. The player has two playback modes, linear
(original order) and shuffled
(shuffled order). In linear
mode, the original order should be updated, without affecting the shuffled order. In shuffled
mode, the shuffled order should be updated, without updating the original order.
In other terms: I need two separate queue orders that I can toggle between (using _audioHandler.setShuffleMode()
), and need to reorder each queue order individually without affecting the other one.
Trying to implement this using just_audio
and audio_service
, I just can't figure out a way to do this.
I've tried reordering by calling ConcatenatingAudioSource.move()
, but there seem to be two problems:
- Reordering shuffled indices doesn't work, as the index is inserted "at random positions". I've managed to get this to work at some point, but not without issues.
- Reordering linear indices always affects the shuffled indices.
I've also tried implementing a custom ShuffleOrder
and passing that to the ConcatenatingAudioSource
. If I try to implement a move()
method for it, I can successfully update the shuffled indices without affecting the linear indices, but sadly the player then doesn't seem to notice the updated indices.
I also looked at the playlist example from audio_service
, but this has the same problem: reordering works fine in linear and shuffled mode, but also affects the indices of the other mode.
Here's a video showing that reordering clearly isn't working as intended:
https://i.imgur.com/OaRLqFb.mp4
I've also looked at other flutter apps using just_audio
and audio_service
, but they either have the same problem, disable reordering when shuffle is active, or don't support reordering at all.
Any pointers would be appreciated!