just_audio shuffleIndicesStream gives wrong order

38 views Asked by At

When I start to listen shuffleIndicesStream, it gives me empty list. Then, it gives me random indices list like [0, 5, 3, 1, 4, 2]. My playlist is not shuffling when it's created. I have player wrapper class called MyAuioHandler that extends audio_srvice's AudioHandler class.

I removed any shuffling methods, but the outputs was the same.

1

There are 1 answers

0
Ryan Heise On

shuffleIndices is defined as the indices generated by shuffle() whether or not shuffle mode is currently enabled.

effectiveIndices returns shuffleIndices if shuffle mode is enabled, otherwise returns the normal indices. You probably want something like that.

There is no direct stream for that, although there is one for sequenceState which you could map to what you want:

player.sequenceStateStream
    .map((state) => state.effectiveIndices)
    .distinct(IterableEquality().equals);

IterableEquality comes from the "collection" package.

Or, if you want to handle it within your own code, you can keep using shuffleIndices (or its stream) and just check if shuffle mode is enabled before you use it.