|
18 | 18 | import xyz.gianlu.librespot.player.remote.Remote3Page; |
19 | 19 | import xyz.gianlu.librespot.player.remote.Remote3Track; |
20 | 20 | import xyz.gianlu.librespot.player.tracks.PlayablesProvider; |
21 | | -import xyz.gianlu.librespot.player.tracks.PlaylistProvider; |
| 21 | +import xyz.gianlu.librespot.player.tracks.ShuffleableProvider; |
22 | 22 | import xyz.gianlu.librespot.player.tracks.StationProvider; |
23 | 23 | import xyz.gianlu.librespot.spirc.SpotifyIrc; |
24 | 24 |
|
@@ -80,31 +80,31 @@ boolean isStatus(@NotNull Spirc.PlayStatus status) { |
80 | 80 |
|
81 | 81 | void setShuffle(boolean shuffle) { |
82 | 82 | state.setShuffle(shuffle && (playablesProvider == null || playablesProvider.canShuffle())); |
83 | | - if (state.getShuffle()) shuffleTracks(false); |
84 | | - else unshuffleTracks(); |
| 83 | + if (state.getShuffle()) shuffleContent(false); |
| 84 | + else unshuffleContent(); |
85 | 85 | } |
86 | 86 |
|
87 | 87 | private void loadPlayablesProvider(@NotNull String uri) throws SpotifyContext.UnsupportedContextException { |
88 | 88 | SpotifyContext context = SpotifyContext.from(uri); |
89 | 89 | playablesProvider = context.initProvider(session, state); |
90 | 90 | } |
91 | 91 |
|
92 | | - private void shuffleTracks(boolean fully) { |
| 92 | + private void shuffleContent(boolean fully) { |
93 | 93 | if (playablesProvider == null) return; |
94 | 94 |
|
95 | | - if (playablesProvider.canShuffle() && playablesProvider instanceof PlaylistProvider) |
96 | | - ((PlaylistProvider) playablesProvider).shuffleTracks(session.random(), fully); |
| 95 | + if (playablesProvider.canShuffle() && playablesProvider instanceof ShuffleableProvider) |
| 96 | + ((ShuffleableProvider) playablesProvider).shuffleContent(session.random(), fully); |
97 | 97 | else |
98 | | - LOGGER.warn("Cannot shuffle TracksProvider: " + playablesProvider); |
| 98 | + LOGGER.warn("Cannot shuffle provider: " + playablesProvider); |
99 | 99 | } |
100 | 100 |
|
101 | | - private void unshuffleTracks() { |
| 101 | + private void unshuffleContent() { |
102 | 102 | if (playablesProvider == null) return; |
103 | 103 |
|
104 | | - if (playablesProvider.canShuffle() && playablesProvider instanceof PlaylistProvider) |
105 | | - ((PlaylistProvider) playablesProvider).unshuffleTracks(); |
| 104 | + if (playablesProvider.canShuffle() && playablesProvider instanceof ShuffleableProvider) |
| 105 | + ((ShuffleableProvider) playablesProvider).unshuffleContent(); |
106 | 106 | else |
107 | | - LOGGER.warn("Cannot unshuffle TracksProvider: " + playablesProvider); |
| 107 | + LOGGER.warn("Cannot unshuffle provider: " + playablesProvider); |
108 | 108 | } |
109 | 109 |
|
110 | 110 | void updated() { |
@@ -163,9 +163,9 @@ int getTrackCount() { |
163 | 163 | void loadStation(@NotNull MercuryRequests.StationsWrapper station) throws SpotifyContext.UnsupportedContextException { |
164 | 164 | state.setContextUri(station.uri()); |
165 | 165 |
|
166 | | - state.setPlayingTrackIndex(0); |
167 | 166 | state.clearTrack(); |
168 | 167 | state.addAllTrack(station.tracks()); |
| 168 | + state.setPlayingTrackIndex(0); |
169 | 169 | SpotifyIrc.trimTracks(state); |
170 | 170 |
|
171 | 171 | loadPlayablesProvider(station.uri()); |
@@ -228,7 +228,7 @@ private void loadPage(@NotNull Remote3Page page, @Nullable TrackSelector selecto |
228 | 228 | state.setPlayingTrackIndex(selector == null ? 0 : selector.playingIndex()); |
229 | 229 | SpotifyIrc.trimTracks(state); |
230 | 230 |
|
231 | | - if (state.getShuffle()) shuffleTracks(selector == null || !selector.findMatch()); |
| 231 | + if (state.getShuffle()) shuffleContent(selector == null || !selector.findMatch()); |
232 | 232 | } |
233 | 233 |
|
234 | 234 | void load(@NotNull Remote3Frame frame) throws IOException, MercuryClient.MercuryException, SpotifyContext.UnsupportedContextException { |
|
0 commit comments