diff options
-rw-r--r-- | apps/tree.c | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/apps/tree.c b/apps/tree.c index a71a60e9cb..59966a5800 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -172,7 +172,7 @@ static int start=0; | |||
172 | static int dirpos[MAX_DIR_LEVELS]; | 172 | static int dirpos[MAX_DIR_LEVELS]; |
173 | static int cursorpos[MAX_DIR_LEVELS]; | 173 | static int cursorpos[MAX_DIR_LEVELS]; |
174 | static int dirlevel=0; | 174 | static int dirlevel=0; |
175 | static bool playing = false; | 175 | static int playing = 0; |
176 | static char currdir[255]; | 176 | static char currdir[255]; |
177 | 177 | ||
178 | /* QUICK HACK! this should be handled by the playlist code later */ | 178 | /* QUICK HACK! this should be handled by the playlist code later */ |
@@ -180,25 +180,36 @@ char* peek_next_track(int type) | |||
180 | { | 180 | { |
181 | static char buf[256]; | 181 | static char buf[256]; |
182 | 182 | ||
183 | /* next-song only works when not browsing */ | 183 | /* next-song only works when playing */ |
184 | if (!playing) | 184 | if (!playing) |
185 | return NULL; | 185 | return NULL; |
186 | 186 | ||
187 | /* get next track in dir */ | 187 | switch(playing) { |
188 | while (dircursor + start + 1 < numentries ) { | 188 | default: |
189 | if(dircursor+1 < TREE_MAX_ON_SCREEN) | 189 | case 1: |
190 | /* play-full-dir mode */ | ||
191 | |||
192 | /* get next track in dir */ | ||
193 | while (dircursor + start + 1 < numentries ) { | ||
194 | if(dircursor+1 < TREE_MAX_ON_SCREEN) | ||
190 | dircursor++; | 195 | dircursor++; |
191 | else | 196 | else |
192 | start++; | 197 | start++; |
193 | if ( dircacheptr[dircursor+start]->file && | 198 | if ( dircacheptr[dircursor+start]->file && |
194 | dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') { | 199 | dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') { |
195 | snprintf(buf,sizeof buf,"%s/%s", | 200 | snprintf(buf,sizeof buf,"%s/%s", |
196 | currdir, dircacheptr[dircursor+start]->name ); | 201 | currdir, dircacheptr[dircursor+start]->name ); |
197 | lcd_clear_display(); | 202 | lcd_clear_display(); |
198 | lcd_puts(0,0,"<Playing>"); | 203 | lcd_puts(0,0,"<Playing>"); |
199 | lcd_puts(0,1,"<all files>"); | 204 | lcd_puts(0,1,"<all files>"); |
200 | return buf; | 205 | return buf; |
201 | } | 206 | } |
207 | } | ||
208 | break; | ||
209 | |||
210 | case 2: | ||
211 | /* playlist mode */ | ||
212 | return playlist_next(type); | ||
202 | } | 213 | } |
203 | 214 | ||
204 | return NULL; | 215 | return NULL; |
@@ -286,13 +297,25 @@ bool dirbrowse(char *root) | |||
286 | dircursor=0; | 297 | dircursor=0; |
287 | start=0; | 298 | start=0; |
288 | } else { | 299 | } else { |
289 | playing = true; | 300 | int len= |
290 | playtune(currdir, dircacheptr[dircursor+start]->name); | 301 | strlen(dircacheptr[dircursor+start]->name); |
291 | playing = false; | 302 | if((len > 4) && |
303 | !strcmp(&dircacheptr[dircursor+start]->name[len-4], | ||
304 | ".m3u")) { | ||
305 | playing = 2; | ||
306 | play_list(currdir, dircacheptr[dircursor+start]->name); | ||
307 | } | ||
308 | |||
309 | else { | ||
310 | |||
311 | playing = 1; | ||
312 | playtune(currdir, dircacheptr[dircursor+start]->name); | ||
313 | playing = 0; | ||
292 | #ifdef HAVE_LCD_BITMAP | 314 | #ifdef HAVE_LCD_BITMAP |
293 | lcd_setmargins(0, MARGIN_Y); | 315 | lcd_setmargins(0, MARGIN_Y); |
294 | lcd_setfont(0); | 316 | lcd_setfont(0); |
295 | #endif | 317 | #endif |
318 | } | ||
296 | } | 319 | } |
297 | 320 | ||
298 | numentries = showdir(currdir, start); | 321 | numentries = showdir(currdir, start); |