summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/playlist.c4
-rw-r--r--apps/playlist.h4
-rw-r--r--apps/tree.c34
3 files changed, 15 insertions, 27 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 465470c069..44d1e34349 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -153,13 +153,15 @@ char* playlist_next(int steps)
153 } 153 }
154} 154}
155 155
156void play_list(char *dir, char *file) 156void play_list(char *dir, char *file, int start_index)
157{ 157{
158 char *sep=""; 158 char *sep="";
159 int dirlen; 159 int dirlen;
160 160
161 empty_playlist(); 161 empty_playlist();
162 162
163 playlist.index = start_index;
164
163 /* If file is NULL, the list is in RAM */ 165 /* If file is NULL, the list is in RAM */
164 if(file) { 166 if(file) {
165 lcd_clear_display(); 167 lcd_clear_display();
diff --git a/apps/playlist.h b/apps/playlist.h
index a218209857..2e3d6a3e27 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -37,10 +37,10 @@ typedef struct
37 bool in_ram; /* True if the playlist is RAM-based */ 37 bool in_ram; /* True if the playlist is RAM-based */
38} playlist_info_t; 38} playlist_info_t;
39 39
40//extern playlist_info_t playlist; 40extern playlist_info_t playlist;
41extern bool playlist_shuffle; 41extern bool playlist_shuffle;
42 42
43void play_list(char *dir, char *file); 43void play_list(char *dir, char *file, int start_index);
44char* playlist_next(int steps); 44char* playlist_next(int steps);
45void randomise_playlist( unsigned int seed ); 45void randomise_playlist( unsigned int seed );
46void sort_playlist(void); 46void sort_playlist(void);
diff --git a/apps/tree.c b/apps/tree.c
index 6e4b6f7e8a..733545aa17 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -109,12 +109,13 @@ extern unsigned char bitmap_icons_6x8[LastIcon][6];
109#define TREE_ATTR_M3U 0x80 /* unused by FAT attributes */ 109#define TREE_ATTR_M3U 0x80 /* unused by FAT attributes */
110#define TREE_ATTR_MP3 0x40 /* unused by FAT attributes */ 110#define TREE_ATTR_MP3 0x40 /* unused by FAT attributes */
111 111
112static void build_playlist(int start_index) 112static void build_playlist(void)
113{ 113{
114 int i; 114 int i;
115 115
116 playlist_clear(); 116 playlist_clear();
117 for(i = start_index;i < filesindir;i++) 117
118 for(i = 0;i < filesindir;i++)
118 { 119 {
119 if(dircacheptr[i]->attr & TREE_ATTR_MP3) 120 if(dircacheptr[i]->attr & TREE_ATTR_MP3)
120 { 121 {
@@ -251,7 +252,6 @@ static int start=0;
251static int dirpos[MAX_DIR_LEVELS]; 252static int dirpos[MAX_DIR_LEVELS];
252static int cursorpos[MAX_DIR_LEVELS]; 253static int cursorpos[MAX_DIR_LEVELS];
253static int dirlevel=0; 254static int dirlevel=0;
254static int play_mode = 0;
255static char currdir[MAX_PATH]; 255static char currdir[MAX_PATH];
256 256
257/* QUICK HACK! this should be handled by the playlist code later */ 257/* QUICK HACK! this should be handled by the playlist code later */
@@ -303,8 +303,6 @@ bool dirbrowse(char *root)
303 button = button_get(true); 303 button = button_get(true);
304 switch ( button ) { 304 switch ( button ) {
305 case TREE_EXIT: 305 case TREE_EXIT:
306 if ( play_mode == 1 )
307 play_mode = 0;
308 i=strlen(currdir); 306 i=strlen(currdir);
309 if (i>1) { 307 if (i>1) {
310 while (currdir[i-1]!='/') 308 while (currdir[i-1]!='/')
@@ -328,7 +326,6 @@ bool dirbrowse(char *root)
328#ifdef HAVE_RECORDER_KEYPAD 326#ifdef HAVE_RECORDER_KEYPAD
329 case BUTTON_OFF: 327 case BUTTON_OFF:
330 mpeg_stop(); 328 mpeg_stop();
331 play_mode = 0;
332 status_set_playmode(STATUS_STOP); 329 status_set_playmode(STATUS_STOP);
333 break; 330 break;
334#endif 331#endif
@@ -349,8 +346,6 @@ bool dirbrowse(char *root)
349 } 346 }
350 347
351 if (dircacheptr[dircursor+start]->attr & ATTR_DIRECTORY) { 348 if (dircacheptr[dircursor+start]->attr & ATTR_DIRECTORY) {
352 if ( play_mode == 1 )
353 play_mode = 0;
354 memcpy(currdir,buf,sizeof(currdir)); 349 memcpy(currdir,buf,sizeof(currdir));
355 if ( dirlevel < MAX_DIR_LEVELS ) { 350 if ( dirlevel < MAX_DIR_LEVELS ) {
356 dirpos[dirlevel] = start; 351 dirpos[dirlevel] = start;
@@ -363,16 +358,14 @@ bool dirbrowse(char *root)
363 lcd_stop_scroll(); 358 lcd_stop_scroll();
364 if(dircacheptr[dircursor+start]->attr & TREE_ATTR_M3U ) 359 if(dircacheptr[dircursor+start]->attr & TREE_ATTR_M3U )
365 { 360 {
366 play_mode = 2; 361 play_list(currdir,
367 play_list(currdir, dircacheptr[dircursor+start]->name); 362 dircacheptr[dircursor+start]->name, 0);
368 status_set_playmode(STATUS_PLAY);
369 } 363 }
370 else { 364 else {
371 build_playlist(dircursor+start); 365 build_playlist();
372 play_mode = 2; 366 play_list(currdir, NULL, dircursor+start);
373 play_list(currdir, NULL);
374 status_set_playmode(STATUS_PLAY);
375 } 367 }
368 status_set_playmode(STATUS_PLAY);
376 status_draw(); 369 status_draw();
377 lcd_stop_scroll(); 370 lcd_stop_scroll();
378 rc = wps_show(); 371 rc = wps_show();
@@ -384,7 +377,6 @@ bool dirbrowse(char *root)
384 dirlevel = 0; 377 dirlevel = 0;
385 dircursor = 0; 378 dircursor = 0;
386 start = 0; 379 start = 0;
387 play_mode = 0;
388 } 380 }
389 } 381 }
390 restore = true; 382 restore = true;
@@ -582,12 +574,8 @@ bool dirbrowse(char *root)
582 574
583 case BUTTON_ON: 575 case BUTTON_ON:
584 browse_speed = 0; 576 browse_speed = 0;
585 /* The mpeg thread may have stopped playing, so we'd 577 if (mpeg_is_playing())
586 better update our status */ 578 {
587 if(!mpeg_is_playing())
588 play_mode = 0;
589
590 if ( play_mode ) {
591 lcd_stop_scroll(); 579 lcd_stop_scroll();
592 rc = wps_show(); 580 rc = wps_show();
593 if(rc == SYS_USB_CONNECTED) 581 if(rc == SYS_USB_CONNECTED)
@@ -598,7 +586,6 @@ bool dirbrowse(char *root)
598 dirlevel = 0; 586 dirlevel = 0;
599 dircursor = 0; 587 dircursor = 0;
600 start = 0; 588 start = 0;
601 play_mode = 0;
602 } 589 }
603 restore = true; 590 restore = true;
604 } 591 }
@@ -620,7 +607,6 @@ bool dirbrowse(char *root)
620 dirlevel = 0; 607 dirlevel = 0;
621 dircursor = 0; 608 dircursor = 0;
622 start = 0; 609 start = 0;
623 play_mode = 0;
624 break; 610 break;
625#endif 611#endif
626 } 612 }