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
Add ShuffleOrder.getShuffledIndex and .getUnshuffledIndex for ease of use. #5426
Comments
The
If you make changes to the playlist after that point, the changes are automatically reflected in the shuffled order. For example if you move the source Two further points:
|
The method
is private in Exoplayer and i do not have access to it |
It's public in the current release, so maybe you need to update. |
alright , i updated, here is where it gets tricky :)
on Shuffle we have
so when i move Track A to Track E
when i skip to next track , it plays someother track apart instead of C then returns to the normal flow. something like that so my question is am i to send the position of current track in original list to exoplayer or the position of current track in shuffled list. for the test above, i am using position of the list on the UI which should mean position of song in shuffled list. |
Enabling the shuffle mode does only change the order in which media sources are played, not their actual order in the playlist. That means This behaviour also means that Would it help to have methods |
that would be nice because i have something like that to0
i just needed a pointer. I will work accordingly. Thanks for all |
Reopening to mark as an enhancement to add these methods. |
To further simplify updates to the shuffled order, we should also add a method like |
@tonihei I'm also facing a similar issue as @mathemandy in the comment quoted above. The next track reported by the Steps to reproduce:
Other observations:
Code used to query the timeline:val Player.currentMediaItemsShuffled: List<MediaItem>
get() = if (shuffleModeEnabled) {
shuffledMediaItemsIndices.map { getMediaItemAt(it) }
} else {
currentMediaItems
}
val Player.shuffledMediaItemsIndices: List<Int>
get() {
val indices = mutableListOf<Int>()
var index = currentTimeline.getFirstWindowIndex(shuffleModeEnabled)
if (index == -1) {
return emptyList()
}
repeat(currentTimeline.windowCount) {
indices += index
index = currentTimeline.getNextWindowIndex(index, Player.REPEAT_MODE_OFF, shuffleModeEnabled)
}
return indices
}
|
Continuing from Issue #4915 i was able to come up with my own implementation of my Own Shuffle Order which is bare but works.
So the idea of mine is that when shuffle is clicked, the current position becomes the first song and the remaining length of the song is shuffled.
i make the player use the shuffle Order like this
I used a handler to delay adding the shuffle order to the media source, because if i do it immediately,
exoplayer
thinks the shuffleOrder is longer than the mediaSource length and callsCloneAndRemove
method of the shuffle order which isn't implemented and crashes the app. So with the handler, its sure the player would be ready before the shuffle order is set :) .What brings me here is the unimplemented Methods
ShuffleOrder cloneAndRemove(int removalIndex);
ShuffleOrder cloneAndInsert(int insertionIndex, int insertionCount);
which i didnt implement because i didnt understand what the
defaultShuffleOrder
was doing.Observation.
When i am in shuffle mode and i try to move a song to a new position, the above methods .are called, so because initially i returned
null
the app crashes at that point. to avoid the app crash, i took Exoplayer's default implementation of that method to mine. it does not crash but it does scatter the list :)i would need help as to how to implement those method that when i move a song in shuffled mode to another position, it behaves normally without randomising the list anymore
Assuming i have a Shuffled list
moving song 1 to song 3 should not change the order of 2 and 4.
I hope i am clear enough. Thank you.
The text was updated successfully, but these errors were encountered: