diff --git a/apps/main_menu.c b/apps/main_menu.c index 25ab12e97b..fb286eca98 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c @@ -169,18 +169,29 @@ void scroll_speed(void) void shuffle(void) { + bool done = false; + lcd_clear_display(); - if(playlist.amount) { - lcd_puts(0,0,"Shuffling..."); + lcd_puts(0,0,"[Shuffle]"); + + while ( !done ) { + lcd_puts(0,1,playlist_shuffle ? "on " : "off"); lcd_update(); - randomise_playlist( &playlist, current_tick ); - lcd_puts(0,1,"Done."); + + switch ( button_get(true) ) { +#ifdef HAVE_RECORDER_KEYPAD + case BUTTON_LEFT: +#else + case BUTTON_STOP: +#endif + done = true; + break; + + default: + playlist_shuffle = !playlist_shuffle; + break; + } } - else { - lcd_puts(0,0,"No playlist"); - } - lcd_update(); - sleep(HZ); } void main_menu(void) diff --git a/apps/playlist.c b/apps/playlist.c index 942a5785b1..f1bcfaa6e9 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -31,6 +31,7 @@ #include "kernel.h" playlist_info_t playlist; +bool playlist_shuffle = false; char now_playing[256]; @@ -101,9 +102,13 @@ void play_list(char *dir, char *file) /* add track indices to playlist data structure */ add_indices_to_playlist(&playlist); - /* if shuffle is wanted, this is where to do that */ + if(playlist_shuffle) { + lcd_puts(0,0,"Shuffling..."); + lcd_update(); + randomise_playlist( &playlist, current_tick ); + } - lcd_puts(0,0,"Complete. "); + lcd_puts(0,0,"Playing... "); lcd_update(); /* also make the first song get playing */ mpeg_play(playlist_next(0)); diff --git a/apps/playlist.h b/apps/playlist.h index 300c7aab65..2517d2b877 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -20,6 +20,8 @@ #ifndef __PLAYLIST_H__ #define __PLAYLIST_H__ +#include + /* playlist data */ #define MAX_PLAYLIST_SIZE 10000 @@ -33,6 +35,7 @@ typedef struct } playlist_info_t; extern playlist_info_t playlist; +extern bool playlist_shuffle; void play_list(char *dir, char *file); char* playlist_next(int type);