From fc2bb6cd2086045d8261b0bf95703510a3aa1bc6 Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Mon, 17 Jun 2002 10:36:42 +0000 Subject: Made playlist shuffle an option instead of an action git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1031 a1c6a512-1295-4272-9138-f99709370657 --- apps/main_menu.c | 29 ++++++++++++++++++++--------- apps/playlist.c | 9 +++++++-- apps/playlist.h | 3 +++ 3 files changed, 30 insertions(+), 11 deletions(-) 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."); - } - else { - lcd_puts(0,0,"No playlist"); + + 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; + } } - 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); -- cgit v1.2.3