Skip to content

Reset currentWindowIndex when changing MediaSource position #4791

@gbirk

Description

@gbirk

I'm working on my own shuffle implementation for a music player app. When the user press shuffle, I need to put the currently playing track at the top of the queue (first position). I could not find any solution for this using the ExoPlayer shuffle mode, so I decided to create my own solution by moving the MediaSource objects on the playlist.

Right now I'm saving a reference of ConcatenatingMediaSource as an attribute and using moveMediaSource to change the positions. I'm not calling prepare or seek before changing the positions.

Let's say that the currently playing index is 4. Then the user hits shuffle and I move the playing item to position 0 by using moveMediaSource. If the user hits next, I would expect the next index to be 1, because I moved the playing item to position 0. But what I'm seeing is that the next index is being reported as 5. Sometimes even another random index.

How I'm suppose to achieve this behavior? There is a way to reset the currently playing index (getCurrentWindowIndex())? Or should I implement this in a different way?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions