media icon indicating copy to clipboard operation
media copied to clipboard

ExoPlayer.moveMediaItems does not update the shuffle order (Copy)

Open OxygenCobalt opened this issue 1 year ago • 5 comments

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 bugreport to [email protected] after filing this issue.

OxygenCobalt avatar May 17 '24 22:05 OxygenCobalt

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 avatar May 20 '24 11:05 oceanjules

@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.

OxygenCobalt avatar May 20 '24 17:05 OxygenCobalt

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.

OxygenCobalt avatar Jul 25 '24 03:07 OxygenCobalt

bump - having the same issue

Tr736 avatar Mar 04 '25 10:03 Tr736

theres now a method to override move action from default no-op to something else in ShuffleOrder interface. this can probably be closed?

nift4 avatar Jun 11 '25 14:06 nift4