summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-08-19 12:45:01 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-08-19 12:45:01 +0000
commit5e5f1e247b8f8596a8651f9119ec769d3e84c428 (patch)
tree3d730bc8137ef94404e4fee511ff0c259586341a
parent43bcd823b7258ff763b93ca868f8ed9745a4f9df (diff)
downloadrockbox-5e5f1e247b8f8596a8651f9119ec769d3e84c428.tar.gz
rockbox-5e5f1e247b8f8596a8651f9119ec769d3e84c428.zip
When shuffle is ENABLED. And you press PLAY in a dir, the selected song
is now the first song to get played. To do this, we first remember which song that was selected, shuffle the list and then find the selected song in the shuffled list and play that. This will have some interesting side effects if the song ends up for example last in the shuffled list when we consider not always doing repeat-all as then it'll reach the end of the playlist after one song. We could optionally put the selected song first in the playlist and then shuffle all the rest, as that would possibly be closer to what people will assume it will do. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1803 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playlist.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index f3081397f6..9bd42941bc 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -167,15 +167,18 @@ char* playlist_next(int steps, int* index)
167 } 167 }
168} 168}
169 169
170void play_list(char *dir, 170/*
171 char *file, 171 * This function is called to start playback of a given playlist. This
172 int start_index, 172 * playlist may be stored in RAM (when using full-dir playback).
173 int start_offset, 173 */
174 int random_seed ) 174void play_list(char *dir, /* "current directory" */
175 char *file, /* playlist */
176 int start_index, /* index in the playlist */
177 int start_offset, /* offset in the file */
178 int random_seed ) /* used for shuffling */
175{ 179{
176 char *sep=""; 180 char *sep="";
177 int dirlen; 181 int dirlen;
178
179 empty_playlist(); 182 empty_playlist();
180 183
181 playlist.index = start_index; 184 playlist.index = start_index;
@@ -216,8 +219,31 @@ void play_list(char *dir,
216 lcd_puts(0,LINE_Y,"Shuffling..."); 219 lcd_puts(0,LINE_Y,"Shuffling...");
217 status_draw(); 220 status_draw();
218 lcd_update(); 221 lcd_update();
222 randomise_playlist( random_seed );
223 }
224 else {
225 int i;
226
227 /* store the seek position before the shuffle */
228 int seek_pos = playlist.indices[start_index];
229
230 /* now shuffle around the indices */
231 randomise_playlist( random_seed );
232
233 /* Because the playlists in RAM is always dir-based playlists,
234 we want the selected file played first so we scan the list
235 for that file to be able to play that one first. */
236
237 for(i=0; i< playlist.amount; i++) {
238 if(seek_pos == playlist.indices[i]) {
239 /* here's the start song! yiepee! */
240 playlist.index = i;
241 break; /* now stop searching */
242 }
243 }
244 /* if we for any reason wouldn't find the index again, it won't
245 set the index again and we should start at index 0 instead */
219 } 246 }
220 randomise_playlist( random_seed );
221 } 247 }
222 248
223 if(!playlist.in_ram) { 249 if(!playlist.in_ram) {