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 now_playing[256];
|
||||||
|
|
||||||
char* playlist_next(int type)
|
char* playlist_next(int steps)
|
||||||
{
|
{
|
||||||
int seek = playlist.indices[playlist.index];
|
int seek;
|
||||||
int max;
|
int max;
|
||||||
int fd;
|
int fd;
|
||||||
int i;
|
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);
|
fd = open(playlist.filename, O_RDONLY);
|
||||||
if(-1 != fd) {
|
if(-1 != fd) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ extern playlist_info_t playlist;
|
||||||
extern bool playlist_shuffle;
|
extern bool playlist_shuffle;
|
||||||
|
|
||||||
void play_list(char *dir, char *file);
|
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 randomise_playlist( playlist_info_t *playlist, unsigned int seed );
|
||||||
void empty_playlist( playlist_info_t *playlist );
|
void empty_playlist( playlist_info_t *playlist );
|
||||||
void add_indices_to_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];
|
static char currdir[255];
|
||||||
|
|
||||||
/* QUICK HACK! this should be handled by the playlist code later */
|
/* 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];
|
static char buf[256];
|
||||||
|
|
||||||
|
@ -204,6 +204,7 @@ char* peek_next_track(int type)
|
||||||
/* play-full-dir mode */
|
/* play-full-dir mode */
|
||||||
|
|
||||||
/* get next track in dir */
|
/* get next track in dir */
|
||||||
|
if ( steps == 1 ) {
|
||||||
while (dircursor + start + 1 < numentries ) {
|
while (dircursor + start + 1 < numentries ) {
|
||||||
if(dircursor+1 < TREE_MAX_ON_SCREEN)
|
if(dircursor+1 < TREE_MAX_ON_SCREEN)
|
||||||
dircursor++;
|
dircursor++;
|
||||||
|
@ -213,17 +214,29 @@ char* peek_next_track(int type)
|
||||||
dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
|
dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
|
||||||
snprintf(buf,sizeof buf,"%s/%s",
|
snprintf(buf,sizeof buf,"%s/%s",
|
||||||
currdir, dircacheptr[dircursor+start]->name );
|
currdir, dircacheptr[dircursor+start]->name );
|
||||||
lcd_clear_display();
|
|
||||||
lcd_puts(0,0,"<Playing>");
|
|
||||||
lcd_puts(0,1,"<all files>");
|
|
||||||
return buf;
|
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;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
/* playlist mode */
|
/* playlist mode */
|
||||||
return playlist_next(type);
|
return playlist_next(steps);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -313,8 +326,9 @@ bool dirbrowse(char *root)
|
||||||
else {
|
else {
|
||||||
|
|
||||||
playing = 1;
|
playing = 1;
|
||||||
playtune(buf);
|
mpeg_play(buf);
|
||||||
playing = 0;
|
lcd_stop_scroll();
|
||||||
|
wps_show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
restore = true;
|
restore = true;
|
||||||
|
@ -367,7 +381,6 @@ bool dirbrowse(char *root)
|
||||||
|
|
||||||
if ( restore ) {
|
if ( restore ) {
|
||||||
/* restore display */
|
/* restore display */
|
||||||
/* TODO: this is just a copy from BUTTON_STOP, fix it */
|
|
||||||
numentries = showdir(currdir, start);
|
numentries = showdir(currdir, start);
|
||||||
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
|
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
|
#ifdef HAVE_RECORDER_KEYPAD
|
||||||
case BUTTON_UP:
|
case BUTTON_UP:
|
||||||
#else
|
|
||||||
case BUTTON_RIGHT:
|
|
||||||
#endif
|
|
||||||
global_settings.volume += 2;
|
global_settings.volume += 2;
|
||||||
if(global_settings.volume > 100)
|
if(global_settings.volume > 100)
|
||||||
global_settings.volume = 100;
|
global_settings.volume = 100;
|
||||||
mpeg_volume(global_settings.volume);
|
mpeg_volume(global_settings.volume);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef HAVE_RECORDER_KEYPAD
|
|
||||||
case BUTTON_DOWN:
|
case BUTTON_DOWN:
|
||||||
#else
|
|
||||||
case BUTTON_LEFT:
|
|
||||||
#endif
|
|
||||||
global_settings.volume -= 2;
|
global_settings.volume -= 2;
|
||||||
if(global_settings.volume < 0)
|
if(global_settings.volume < 0)
|
||||||
global_settings.volume = 0;
|
global_settings.volume = 0;
|
||||||
mpeg_volume(global_settings.volume);
|
mpeg_volume(global_settings.volume);
|
||||||
break;
|
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);
|
sleep(HZ/20);
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,11 +319,7 @@ static int new_file(bool next_track)
|
||||||
{
|
{
|
||||||
char *trackname;
|
char *trackname;
|
||||||
|
|
||||||
if (next_track)
|
trackname = peek_next_track( next_track ? 1 : -1 );
|
||||||
trackname = peek_next_track(0);
|
|
||||||
else
|
|
||||||
trackname = peek_prev_track(0);
|
|
||||||
|
|
||||||
if ( !trackname )
|
if ( !trackname )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue