diff options
Diffstat (limited to 'apps/playlist.c')
-rw-r--r-- | apps/playlist.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 27665981f7..0ac848c59c 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -168,12 +168,16 @@ char* playlist_next(int steps, int* index) | |||
168 | /* | 168 | /* |
169 | * This function is called to start playback of a given playlist. This | 169 | * This function is called to start playback of a given playlist. This |
170 | * playlist may be stored in RAM (when using full-dir playback). | 170 | * playlist may be stored in RAM (when using full-dir playback). |
171 | * | ||
172 | * Return: the new index (possibly different due to shuffle) | ||
171 | */ | 173 | */ |
172 | void play_list(char *dir, /* "current directory" */ | 174 | int play_list(char *dir, /* "current directory" */ |
173 | char *file, /* playlist */ | 175 | char *file, /* playlist */ |
174 | int start_index, /* index in the playlist */ | 176 | int start_index, /* index in the playlist */ |
175 | int start_offset, /* offset in the file */ | 177 | bool shuffled_index, /* if TRUE the specified index is for the |
176 | int random_seed ) /* used for shuffling */ | 178 | playlist AFTER the shuffle */ |
179 | int start_offset, /* offset in the file */ | ||
180 | int random_seed ) /* used for shuffling */ | ||
177 | { | 181 | { |
178 | char *sep=""; | 182 | char *sep=""; |
179 | int dirlen; | 183 | int dirlen; |
@@ -235,19 +239,22 @@ void play_list(char *dir, /* "current directory" */ | |||
235 | /* now shuffle around the indices */ | 239 | /* now shuffle around the indices */ |
236 | randomise_playlist( random_seed ); | 240 | randomise_playlist( random_seed ); |
237 | 241 | ||
238 | /* Because the playlists in RAM is always dir-based playlists, | 242 | if(!shuffled_index) { |
239 | we want the selected file played first so we scan the list | 243 | /* The given index was for the unshuffled list, so we need |
240 | for that file to be able to play that one first. */ | 244 | to figure out the index AFTER the shuffle has been made. |
245 | We scan for the seek position we remmber from before. */ | ||
241 | 246 | ||
242 | for(i=0; i< playlist.amount; i++) { | 247 | for(i=0; i< playlist.amount; i++) { |
243 | if(seek_pos == playlist.indices[i]) { | 248 | if(seek_pos == playlist.indices[i]) { |
244 | /* here's the start song! yiepee! */ | 249 | /* here's the start song! yiepee! */ |
245 | playlist.index = i; | 250 | playlist.index = i; |
246 | break; /* now stop searching */ | 251 | break; /* now stop searching */ |
252 | } | ||
247 | } | 253 | } |
254 | /* if we for any reason wouldn't find the index again, it | ||
255 | won't set the index again and we should start at index 0 | ||
256 | instead */ | ||
248 | } | 257 | } |
249 | /* if we for any reason wouldn't find the index again, it won't | ||
250 | set the index again and we should start at index 0 instead */ | ||
251 | } | 258 | } |
252 | } | 259 | } |
253 | 260 | ||
@@ -258,6 +265,8 @@ void play_list(char *dir, /* "current directory" */ | |||
258 | } | 265 | } |
259 | /* also make the first song get playing */ | 266 | /* also make the first song get playing */ |
260 | mpeg_play(start_offset); | 267 | mpeg_play(start_offset); |
268 | |||
269 | return playlist.index; | ||
261 | } | 270 | } |
262 | 271 | ||
263 | /* | 272 | /* |