question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to support reordering during the shuffle

See original GitHub issue

Things I want to do

  • The app shows currently playing items
  • The app allows reordering during the shuffle
  • The result of reordering during the shuffle does not affect the song order before the shuffle

Current approach

Result

Environment

  • ExoPlayer:2.16.1
  • Test Device:
    • Pixel 3(OS 12)
    • Pixel 4(OS 11)
    • Emulator(OS 10)
    • Sample Project

Sample Project

Question

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
toniheicommented, Jul 15, 2022

Fixed by the commit above.

1reaction
marcbaechingercommented, Jan 30, 2022

You correctly do

player.setShuffleOrder(shuffleOrder);
mediaSessionConnector.invalidateMediaSessionQueue()

It looks to me like you are hitting a bug with the masked timeline. With the above code the MediaSessionConnector invalidates the queue which triggers queueNavigator.onTimelineChanged(player). The TimelineQueueNavigator then calls player.getCurrentTimeline() and receives the masked timeline that is created just at the beginning of ExoPlayerImpl.setShuffleOrder(shuffleOrder). The timeline created at that moment does still include the old shuffleOrder and not the one that is passed to the setter.

Looks like that we need to assign the new shuffleOrder before we create the masking timeline.

If this is true what I’m saying, you should receive the new shuffle order later. When the status update arrives from the playback thread.

This should possibly already do the trick as a workaround:

player.setShuffleOrder(shuffleOrder);
Util.createHandlerForCurrentLooper().post(() -> {
    mediaSessionConnector.invalidateMediaSessionQueue();
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Re-ordering posts in your queue - Buffer Help Center
It is sometimes necessary to change the order of the posts in your queue. You can do this by dragging and dropping posts...
Read more >
How To Re-Order & Shuffle Posts In Your Queue
1. Navigate to the Queue and ensure you're in 'List' view · 2. When viewing the posts in your Queue,you will see a...
Read more >
Skip, Shuffle, or Un-Shuffle Posts to Reorder Your Content
To un-shuffle a category so it will post in the default last in, first out order again, follow the steps below: Go to...
Read more >
I can't reorder songs on Ipod shuffle playlist
Check to make sure that, for your iPod shuffle playlist, iTunes shuffle is turned off. Open iTunes and look at the second icon...
Read more >
Help managing/reordering the shuffle queue/list : r/PowerAmp
Press and hold a song in the "queue" menu/screen. On the right side, you can press and move the songs via that weird...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found