You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a custom ShuffleOrder class with four major goals:
when enabling shuffle in one specific item, it will be the first item in shuffled playlist so everything else plays afterwards
when user presses "play next", it will play next even if shuffle is enabled (inserted items are shuffled among themselves and inserted after previous song from normal playlist in shuffle playlist)
support saving and loading from disk
sensible movement of media items
This mostly works fine with more or less hacky approaches for each of the desired features.
However, my custom shuffle order has no chance of reacting to moveMediaItems(): unlike set/add/remove methods, moveMediaItems does not clone and edit the shuffle order. Due to that, moving a playlist item from UI while shuffle is enabled acts unpredictably (the shuffled indices mapping will not change) while my implementation acts as expected by users (insertion point is after the previous item in shuffled list).
Proposed solution
Call shuffleOrder.cloneAndRemove().cloneAndInsert() inside ExoPlayerImpl when moveMediaItems() is called to inform the shuffle order of changes. This allows custom shuffle order implementations to react however they like while not impacting DefaultShuffleOrder (it's still random, just a bit differently random).
Alternatives considered
ForwardingPlayer that, when moveMediaItems() is called, extracts the current copy of the shuffle order using reflection, calling the clone methods and then setShuffleOrder() manually. This is fragile and causes ExoPlayer to reload timeline. However, it works as intended.
The text was updated successfully, but these errors were encountered:
[REQUIRED] Use case description
I wrote a custom ShuffleOrder class with four major goals:
This mostly works fine with more or less hacky approaches for each of the desired features.
However, my custom shuffle order has no chance of reacting to moveMediaItems(): unlike set/add/remove methods, moveMediaItems does not clone and edit the shuffle order. Due to that, moving a playlist item from UI while shuffle is enabled acts unpredictably (the shuffled indices mapping will not change) while my implementation acts as expected by users (insertion point is after the previous item in shuffled list).
Proposed solution
Call shuffleOrder.cloneAndRemove().cloneAndInsert() inside ExoPlayerImpl when moveMediaItems() is called to inform the shuffle order of changes. This allows custom shuffle order implementations to react however they like while not impacting DefaultShuffleOrder (it's still random, just a bit differently random).
Alternatives considered
ForwardingPlayer that, when moveMediaItems() is called, extracts the current copy of the shuffle order using reflection, calling the clone methods and then setShuffleOrder() manually. This is fragile and causes ExoPlayer to reload timeline. However, it works as intended.
The text was updated successfully, but these errors were encountered: