How to support reordering during the shuffle
See original GitHub issueThings 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
- Get currently playing items from MediaControllerCompat.Callback#onQueueChanged
- Customize TimelineQueueEditor, ShuffleOrder
- doesn’t call Player#moveMediaItem when reorder during the shuffle
- generate a new
ShuffleOrder
from the sorted result - call ExoPlayer#setShuffleOrder to update the sort order
Result
- When reordering several times while shuffling, the song order may not be reflected in MediaSession
- doesn’t call MediaControllerCompat.Callback#onQueueChanged
Environment
- ExoPlayer:2.16.1
- Test Device:
- Pixel 3(OS 12)
- Pixel 4(OS 11)
- Emulator(OS 10)
- Sample Project
Sample Project
Question
- Is it correct behavior that sometimes MediaControllerCompat.Callback#onQueueChanged is not executed when ExoPlayer#setShuffleOrder is called?
- Is there a better approach to support reordering during the shuffle?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed by the commit above.
You correctly do
It looks to me like you are hitting a bug with the masked timeline. With the above code the
MediaSessionConnector
invalidates the queue which triggersqueueNavigator.onTimelineChanged(player)
. TheTimelineQueueNavigator
then callsplayer.getCurrentTimeline()
and receives the masked timeline that is created just at the beginning ofExoPlayerImpl.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: