media
                                
                                
                                
                                    media copied to clipboard
                            
                            
                            
                        ExoPlayer.moveMediaItems does not update the shuffle order (Copy)
Version
Media3 main branch
More version details
(This is a reposted issue since the last one was locked for inactivity. I've only recently realized that this issue was not my fault.)
Media3 1.3.1
Devices that reproduce the issue
All
Devices that do not reproduce the issue
N/A
Reproducible in the demo app?
Yes
Reproduction steps
Occurs at any queue move in a shuffled playlist that does not happen to result in the indended shuffled playlist (It's hard to define the specific criteria, sorry). For example, this pseudo-kotlin code:
player.shuffleModeEnabled = true
player.setMediaItems(listOf(dummy1, dummy2, dummy3)) // Assume these are initialized MediaItems
player.moveMediaItems(0, 2) 
Expected result
Assume that the shuffled playlist is: [dummy1, dummy3, dummy2] (i.e shuffled index list of [0, 2, 1]), and the ordered playlist [dummy1, dummy2, dummy3].
Moving the media items as specified in the reproduction steps should as a result:
- Move the ordered playlist, resulting in [dummy2, dummy3, dummy1].
 - Reindex the shuffle order, resulting in a shuffled index list of [2, 1, 0].
 - Move the items in the shuffle order, resulting in a shuffled index list of [1, 0, 2] and a shuffled playlist of [dummy3, dummy2, dummy1].
 
In practice, this should involve another ShuffleOrder override, something like cloneAndMove, that performs this reindexing and item moving.
Actual result
The ShuffleOrder is not even cloned when MediaItems are moved judging by ExoPlayerImpl. Instead, what happens
- Move the ordered playlist, resulting in [dummy3, dummy2, dummy1].
 - Do not reindex the shuffle order, resulting in still a shuffled index list of [0, 2, 1]
 - Do not move anything in the shuffle order, resulting in a shuffled index list of [0, 2, 1] and a shuffled playlist of [dummy3, dummy1, dummy2]. This is entirely incorrect.
 
Media
N/A
Bug Report
- [ ] You will email the zip file produced by 
adb bugreportto [email protected] after filing this issue. 
Hi @OxygenCobalt, It seems like you closed https://github.com/androidx/media/issues/954 yourself. Did you not end up finding a solution to the shuffle order?
@oceanjules No. I originally thought that it was a problem on my end from a misunderstanding on what it meant to move MediaItems, but now I realize that it is a real bug even with normal use of moveMediaItems.
Can anyone still help with this? Getting reports from users about this bug appearing even with my workaround. @marcbaechinger
At minimum I'd want to know how dangerous just flat-out patching it in myself would be. Unsure if I would have to refactor anything related to how ExoPlayer manages/anticipates streams when they are moved around or if the shuffle order changes.
bump - having the same issue
theres now a method to override move action from default no-op to something else in ShuffleOrder interface. this can probably be closed?