forked from len0rd/rockbox
When shuffle is ENABLED. And you press PLAY in a dir, the selected song
is now the first song to get played. To do this, we first remember which song that was selected, shuffle the list and then find the selected song in the shuffled list and play that. This will have some interesting side effects if the song ends up for example last in the shuffled list when we consider not always doing repeat-all as then it'll reach the end of the playlist after one song. We could optionally put the selected song first in the playlist and then shuffle all the rest, as that would possibly be closer to what people will assume it will do. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1803 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
43bcd823b7
commit
5e5f1e247b
1 changed files with 33 additions and 7 deletions
|
|
@ -167,15 +167,18 @@ char* playlist_next(int steps, int* index)
|
|||
}
|
||||
}
|
||||
|
||||
void play_list(char *dir,
|
||||
char *file,
|
||||
int start_index,
|
||||
int start_offset,
|
||||
int random_seed )
|
||||
/*
|
||||
* This function is called to start playback of a given playlist. This
|
||||
* playlist may be stored in RAM (when using full-dir playback).
|
||||
*/
|
||||
void play_list(char *dir, /* "current directory" */
|
||||
char *file, /* playlist */
|
||||
int start_index, /* index in the playlist */
|
||||
int start_offset, /* offset in the file */
|
||||
int random_seed ) /* used for shuffling */
|
||||
{
|
||||
char *sep="";
|
||||
int dirlen;
|
||||
|
||||
empty_playlist();
|
||||
|
||||
playlist.index = start_index;
|
||||
|
|
@ -216,8 +219,31 @@ void play_list(char *dir,
|
|||
lcd_puts(0,LINE_Y,"Shuffling...");
|
||||
status_draw();
|
||||
lcd_update();
|
||||
randomise_playlist( random_seed );
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
|
||||
/* store the seek position before the shuffle */
|
||||
int seek_pos = playlist.indices[start_index];
|
||||
|
||||
/* now shuffle around the indices */
|
||||
randomise_playlist( random_seed );
|
||||
|
||||
/* Because the playlists in RAM is always dir-based playlists,
|
||||
we want the selected file played first so we scan the list
|
||||
for that file to be able to play that one first. */
|
||||
|
||||
for(i=0; i< playlist.amount; i++) {
|
||||
if(seek_pos == playlist.indices[i]) {
|
||||
/* here's the start song! yiepee! */
|
||||
playlist.index = i;
|
||||
break; /* now stop searching */
|
||||
}
|
||||
}
|
||||
/* if we for any reason wouldn't find the index again, it won't
|
||||
set the index again and we should start at index 0 instead */
|
||||
}
|
||||
randomise_playlist( random_seed );
|
||||
}
|
||||
|
||||
if(!playlist.in_ram) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue