forked from len0rd/rockbox
Added next/previous track
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1211 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
72315c29fa
commit
a72f95c2ba
5 changed files with 54 additions and 35 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 );
|
||||
|
|
29
apps/tree.c
29
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,6 +204,7 @@ char* peek_next_track(int type)
|
|||
/* play-full-dir mode */
|
||||
|
||||
/* get next track in dir */
|
||||
if ( steps == 1 ) {
|
||||
while (dircursor + start + 1 < numentries ) {
|
||||
if(dircursor+1 < TREE_MAX_ON_SCREEN)
|
||||
dircursor++;
|
||||
|
@ -213,17 +214,29 @@ char* peek_next_track(int type)
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
24
apps/wps.c
24
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue