Skip to content

notify ShuffleOrder when media item(s) are moved #2226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2025

Conversation

nift4
Copy link

@nift4 nift4 commented Mar 11, 2025

Issue: #1932
Issue: #1381

--

(Extracting a seperate method moveMediaSourceHolders was done to align with insert/remove code. A new default method instead of just implementing that in DefaultShuffleOrder was done because I believe the move detection is not required by simpler shuffle order implementations, and this makes upgrades easier as devs don't have to implement a new function.)

@rohitjoins rohitjoins self-assigned this Mar 17, 2025
@nift4
Copy link
Author

nift4 commented Apr 7, 2025

@rohitjoins @icbaker any chance one of you could take a look?

@nift4
Copy link
Author

nift4 commented May 7, 2025

@marcbaechinger ping since it has been a month, any chance you could take a look at this PR?

@marcbaechinger marcbaechinger self-requested a review May 16, 2025 09:13
Copy link
Contributor

@marcbaechinger marcbaechinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR

@marcbaechinger
Copy link
Contributor

I'm going to send this for internal review now. You may see some more commits being added as I make changes in response to review feedback. Please refrain from pushing any more substantive changes as it will complicate the internal review - thanks!

@marcbaechinger
Copy link
Contributor

Ok, I think I've wrapped my head around what this does. Sorry for the wait and for me being slow.

Currently, when items in the playlist are moved, the shuffle order is kept the same. With your change ExoPlayerImpl calls cloneAndMove(). This makes sense to me as this is consistent with what we do.

but a seperate "move" API is needed for my usecase.

Yeah, acknowledged adding cloneAndMove and calling this in ExoPlayerImpl makes sense to enable re-shuffling upon such an operation.

that shuffle order may decide to not reshuffle in the individual items when a group of items is moved.

I agree with this, but my conclusion would be that the default implementation is a no-op? This would have the advantage that we do not introduce a behavior change to what ExoPlayer is currently doing when a move is performed.

This would still be useful for your use case as I understand you have your own implementation of ShuffleOrder and you can then implement cloneAndMove() to actually re-shuffle.

I guess I'm going to change that accordingly unless you have some strong argument to inverse that procedure.

  1. Add cloneAndMove() to ShuffleOrder. Make the default implementation a no-op
  2. Call the method in ExoPlayerImpl so a custom implementation can re-shuffle in case that's desired.

@marcbaechinger marcbaechinger force-pushed the shuffle branch 2 times, most recently from 2868055 to 82b0bb5 Compare May 21, 2025 12:18
@nift4
Copy link
Author

nift4 commented May 21, 2025

Sounds good to me, thanks :)

@copybara-service copybara-service bot merged commit fe98cd7 into androidx:main Jun 11, 2025
1 check passed
@nift4
Copy link
Author

nift4 commented Jun 11, 2025

Thanks, Marc :)

@nift4 nift4 deleted the shuffle branch June 11, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants