summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-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) {