summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-06-26 23:25:03 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-06-26 23:25:03 +0000
commita72f95c2ba57c5f4764f20044d6ac1ca4be79e4e (patch)
tree0d7431f044538633c97512a5e4133d9796aac561
parent72315c29fa12d14513a06d961a79570f2a37f26a (diff)
downloadrockbox-a72f95c2ba57c5f4764f20044d6ac1ca4be79e4e.zip
rockbox-a72f95c2ba57c5f4764f20044d6ac1ca4be79e4e.tar.gz
rockbox-a72f95c2ba57c5f4764f20044d6ac1ca4be79e4e.tar.bz2
rockbox-a72f95c2ba57c5f4764f20044d6ac1ca4be79e4e.tar.xz
Added next/previous track
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1211 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playlist.c8
-rw-r--r--apps/playlist.h2
-rw-r--r--apps/tree.c49
-rw-r--r--apps/wps.c24
-rw-r--r--firmware/mpeg.c6
5 files changed, 54 insertions, 35 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 5d7ef2f..bd5c2b2 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -35,15 +35,15 @@ bool playlist_shuffle = false;
char now_playing[256];
-char* playlist_next(int type)
+char* playlist_next(int steps)
{
- int seek = playlist.indices[playlist.index];
+ int seek;
int max;
int fd;
int i;
- (void)type; /* prevent compiler warning until this is gets used */
- playlist.index = (playlist.index+1) % playlist.amount;
+ playlist.index = (playlist.index+steps) % playlist.amount;
+ seek = playlist.indices[playlist.index];
fd = open(playlist.filename, O_RDONLY);
if(-1 != fd) {
diff --git a/apps/playlist.h b/apps/playlist.h
index 2517d2b..273a612 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -38,7 +38,7 @@ extern playlist_info_t playlist;
extern bool playlist_shuffle;
void play_list(char *dir, char *file);
-char* playlist_next(int type);
+char* playlist_next(int steps);
void randomise_playlist( playlist_info_t *playlist, unsigned int seed );
void empty_playlist( playlist_info_t *playlist );
void add_indices_to_playlist( playlist_info_t *playlist );
diff --git a/apps/tree.c b/apps/tree.c
index a071ce7..4b16bac 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -190,7 +190,7 @@ static int playing = 0;
static char currdir[255];
/* QUICK HACK! this should be handled by the playlist code later */
-char* peek_next_track(int type)
+char* peek_next_track(int steps)
{
static char buf[256];
@@ -204,26 +204,39 @@ char* peek_next_track(int type)
/* play-full-dir mode */
/* get next track in dir */
- while (dircursor + start + 1 < numentries ) {
- if(dircursor+1 < TREE_MAX_ON_SCREEN)
- dircursor++;
- else
- start++;
- if ( dircacheptr[dircursor+start]->file &&
- dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
- snprintf(buf,sizeof buf,"%s/%s",
- currdir, dircacheptr[dircursor+start]->name );
- lcd_clear_display();
- lcd_puts(0,0,"<Playing>");
- lcd_puts(0,1,"<all files>");
- return buf;
+ if ( steps == 1 ) {
+ while (dircursor + start + 1 < numentries ) {
+ if(dircursor+1 < TREE_MAX_ON_SCREEN)
+ dircursor++;
+ else
+ start++;
+ if ( dircacheptr[dircursor+start]->file &&
+ dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
+ snprintf(buf,sizeof buf,"%s/%s",
+ currdir, dircacheptr[dircursor+start]->name );
+ return buf;
+ }
+ }
+ }
+ else {
+ while (dircursor + start > 0) {
+ if (dircursor > 0)
+ dircursor--;
+ else
+ start--;
+ if ( dircacheptr[dircursor+start]->file &&
+ dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
+ snprintf(buf, sizeof(buf), "%s/%s",
+ currdir, dircacheptr[dircursor+start]->name);
+ return buf;
+ }
}
}
break;
case 2:
/* playlist mode */
- return playlist_next(type);
+ return playlist_next(steps);
}
return NULL;
@@ -313,8 +326,9 @@ bool dirbrowse(char *root)
else {
playing = 1;
- playtune(buf);
- playing = 0;
+ mpeg_play(buf);
+ lcd_stop_scroll();
+ wps_show();
}
}
restore = true;
@@ -367,7 +381,6 @@ bool dirbrowse(char *root)
if ( restore ) {
/* restore display */
- /* TODO: this is just a copy from BUTTON_STOP, fix it */
numentries = showdir(currdir, start);
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
}
diff --git a/apps/wps.c b/apps/wps.c
index 75b68d0..838f8f7 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -146,25 +146,35 @@ void wps_show(void)
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
-#else
- case BUTTON_RIGHT:
-#endif
global_settings.volume += 2;
if(global_settings.volume > 100)
global_settings.volume = 100;
mpeg_volume(global_settings.volume);
break;
-#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
-#else
- case BUTTON_LEFT:
-#endif
global_settings.volume -= 2;
if(global_settings.volume < 0)
global_settings.volume = 0;
mpeg_volume(global_settings.volume);
break;
+#endif
+
+ case BUTTON_LEFT:
+ mpeg_prev();
+ break;
+
+ case BUTTON_RIGHT:
+ mpeg_next();
+ break;
+
+#ifdef HAVE_RECORDER_KEYPAD
+ case BUTTON_OFF:
+#else
+ case BUTTON_DOWN:
+#endif
+ mpeg_stop();
+ break;
}
sleep(HZ/20);
}
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index b1cbf33..31e50ca 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -319,11 +319,7 @@ static int new_file(bool next_track)
{
char *trackname;
- if (next_track)
- trackname = peek_next_track(0);
- else
- trackname = peek_prev_track(0);
-
+ trackname = peek_next_track( next_track ? 1 : -1 );
if ( !trackname )
return -1;