diff options
Diffstat (limited to 'apps/playlist.c')
-rw-r--r-- | apps/playlist.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 038e710829..23c3f5d606 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -68,23 +68,30 @@ int playlist_add(char *filename) | |||
68 | 68 | ||
69 | static int get_next_index(int steps) | 69 | static int get_next_index(int steps) |
70 | { | 70 | { |
71 | int next_index = -1; | 71 | int current_index = playlist.index; |
72 | int next_index = -1; | ||
72 | 73 | ||
73 | switch (global_settings.repeat_mode) | 74 | switch (global_settings.repeat_mode) |
74 | { | 75 | { |
75 | case REPEAT_OFF: | 76 | case REPEAT_OFF: |
76 | next_index = playlist.index+steps; | 77 | if (current_index < playlist.first_index) |
78 | current_index += playlist.amount; | ||
79 | current_index -= playlist.first_index; | ||
80 | |||
81 | next_index = current_index+steps; | ||
77 | if ((next_index < 0) || (next_index >= playlist.amount)) | 82 | if ((next_index < 0) || (next_index >= playlist.amount)) |
78 | next_index = -1; | 83 | next_index = -1; |
84 | else | ||
85 | next_index = (next_index+playlist.first_index)%playlist.amount; | ||
79 | break; | 86 | break; |
80 | 87 | ||
81 | case REPEAT_ONE: | 88 | case REPEAT_ONE: |
82 | next_index = playlist.index; | 89 | next_index = current_index; |
83 | break; | 90 | break; |
84 | 91 | ||
85 | case REPEAT_ALL: | 92 | case REPEAT_ALL: |
86 | default: | 93 | default: |
87 | next_index = (playlist.index+steps) % playlist.amount; | 94 | next_index = (current_index+steps) % playlist.amount; |
88 | while (next_index < 0) | 95 | while (next_index < 0) |
89 | next_index += playlist.amount; | 96 | next_index += playlist.amount; |
90 | break; | 97 | break; |
@@ -212,13 +219,15 @@ int play_list(char *dir, /* "current directory" */ | |||
212 | bool shuffled_index, /* if TRUE the specified index is for the | 219 | bool shuffled_index, /* if TRUE the specified index is for the |
213 | playlist AFTER the shuffle */ | 220 | playlist AFTER the shuffle */ |
214 | int start_offset, /* offset in the file */ | 221 | int start_offset, /* offset in the file */ |
215 | int random_seed ) /* used for shuffling */ | 222 | int random_seed, /* used for shuffling */ |
223 | int first_index ) /* first index of playlist */ | ||
216 | { | 224 | { |
217 | char *sep=""; | 225 | char *sep=""; |
218 | int dirlen; | 226 | int dirlen; |
219 | empty_playlist(); | 227 | empty_playlist(); |
220 | 228 | ||
221 | playlist.index = start_index; | 229 | playlist.index = start_index; |
230 | playlist.first_index = first_index; | ||
222 | 231 | ||
223 | #ifdef HAVE_LCD_BITMAP | 232 | #ifdef HAVE_LCD_BITMAP |
224 | if(global_settings.statusbar) | 233 | if(global_settings.statusbar) |
@@ -283,6 +292,7 @@ int play_list(char *dir, /* "current directory" */ | |||
283 | if(seek_pos == playlist.indices[i]) { | 292 | if(seek_pos == playlist.indices[i]) { |
284 | /* here's the start song! yiepee! */ | 293 | /* here's the start song! yiepee! */ |
285 | playlist.index = i; | 294 | playlist.index = i; |
295 | playlist.first_index = i; | ||
286 | break; /* now stop searching */ | 296 | break; /* now stop searching */ |
287 | } | 297 | } |
288 | } | 298 | } |