mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Accept FS#6464 by Chris Taylor. Adds a "Play Next" playlist insertion
option which replaces the current playlist with the new selection but keeps the current track queued so playback doesnt stop. (minor fixes by me) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11842 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6ee5e38494
commit
be3f29cc11
6 changed files with 80 additions and 2 deletions
|
@ -10442,3 +10442,17 @@
|
||||||
*: "Clear Time?"
|
*: "Clear Time?"
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
id: LANG_REPLACE
|
||||||
|
desc: in onplay menu. Replace the current playlist with a new one.
|
||||||
|
user:
|
||||||
|
<source>
|
||||||
|
*: "Play Next"
|
||||||
|
</source>
|
||||||
|
<dest>
|
||||||
|
*: "Play Next"
|
||||||
|
</dest>
|
||||||
|
<voice>
|
||||||
|
*: "Play Next"
|
||||||
|
</voice>
|
||||||
|
</phrase>
|
||||||
|
|
|
@ -368,6 +368,11 @@ static bool playlist_options(void)
|
||||||
args[i].position = PLAYLIST_INSERT_SHUFFLED;
|
args[i].position = PLAYLIST_INSERT_SHUFFLED;
|
||||||
args[i].queue = true;
|
args[i].queue = true;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
items[i].desc = ID2P(LANG_REPLACE);
|
||||||
|
args[i].position = PLAYLIST_REPLACE;
|
||||||
|
args[i].queue = false;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
|
else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
|
||||||
(selected_file_attr & ATTR_DIRECTORY))
|
(selected_file_attr & ATTR_DIRECTORY))
|
||||||
|
|
|
@ -560,6 +560,33 @@ exit:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removes all tracks, from the playlist, leaving the presently playing
|
||||||
|
* track queued.
|
||||||
|
*/
|
||||||
|
int remove_all_tracks(struct playlist_info *playlist)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if (playlist == NULL)
|
||||||
|
playlist = ¤t_playlist;
|
||||||
|
|
||||||
|
while (playlist->index > 0)
|
||||||
|
if ((result = remove_track_from_playlist(playlist, 0, true)) < 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
while (playlist->amount > 1)
|
||||||
|
if ((result = remove_track_from_playlist(playlist, 1, true)) < 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
if (playlist->amount == 1) {
|
||||||
|
playlist->indices[0] |= PLAYLIST_QUEUED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add track to playlist at specified position. There are five special
|
* Add track to playlist at specified position. There are five special
|
||||||
* positions that can be specified:
|
* positions that can be specified:
|
||||||
|
@ -572,6 +599,8 @@ exit:
|
||||||
* PLAYLIST_INSERT_LAST - Add track to end of playlist
|
* PLAYLIST_INSERT_LAST - Add track to end of playlist
|
||||||
* PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the
|
* PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the
|
||||||
* current playing track and end of playlist
|
* current playing track and end of playlist
|
||||||
|
* PLAYLIST_REPLACE - Erase current playlist, Cue the current track
|
||||||
|
* and inster this track at the end.
|
||||||
*/
|
*/
|
||||||
static int add_track_to_playlist(struct playlist_info* playlist,
|
static int add_track_to_playlist(struct playlist_info* playlist,
|
||||||
const char *filename, int position,
|
const char *filename, int position,
|
||||||
|
@ -648,6 +677,12 @@ static int add_track_to_playlist(struct playlist_info* playlist,
|
||||||
position = insert_position = (rand() % (playlist->amount+1));
|
position = insert_position = (rand() % (playlist->amount+1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case PLAYLIST_REPLACE:
|
||||||
|
if (remove_all_tracks(playlist) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
position = insert_position = playlist->index + 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queue)
|
if (queue)
|
||||||
|
@ -2860,6 +2895,14 @@ int playlist_insert_directory(struct playlist_info* playlist,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (position == PLAYLIST_REPLACE)
|
||||||
|
{
|
||||||
|
if (remove_all_tracks(playlist) == 0)
|
||||||
|
position = PLAYLIST_INSERT_LAST;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (queue)
|
if (queue)
|
||||||
count_str = str(LANG_PLAYLIST_QUEUE_COUNT);
|
count_str = str(LANG_PLAYLIST_QUEUE_COUNT);
|
||||||
else
|
else
|
||||||
|
@ -2871,7 +2914,7 @@ int playlist_insert_directory(struct playlist_info* playlist,
|
||||||
context.position = position;
|
context.position = position;
|
||||||
context.queue = queue;
|
context.queue = queue;
|
||||||
context.count = 0;
|
context.count = 0;
|
||||||
|
|
||||||
cpu_boost(true);
|
cpu_boost(true);
|
||||||
|
|
||||||
result = playlist_directory_tracksearch(dirname, recurse,
|
result = playlist_directory_tracksearch(dirname, recurse,
|
||||||
|
@ -2941,6 +2984,13 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
|
||||||
|
|
||||||
display_playlist_count(count, count_str);
|
display_playlist_count(count, count_str);
|
||||||
|
|
||||||
|
if (position == PLAYLIST_REPLACE)
|
||||||
|
{
|
||||||
|
if (remove_all_tracks(playlist) == 0)
|
||||||
|
position = PLAYLIST_INSERT_LAST;
|
||||||
|
else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
cpu_boost(true);
|
cpu_boost(true);
|
||||||
|
|
||||||
while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0)
|
while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0)
|
||||||
|
|
|
@ -48,7 +48,8 @@ enum {
|
||||||
PLAYLIST_INSERT = -2,
|
PLAYLIST_INSERT = -2,
|
||||||
PLAYLIST_INSERT_LAST = -3,
|
PLAYLIST_INSERT_LAST = -3,
|
||||||
PLAYLIST_INSERT_FIRST = -4,
|
PLAYLIST_INSERT_FIRST = -4,
|
||||||
PLAYLIST_INSERT_SHUFFLED = -5
|
PLAYLIST_INSERT_SHUFFLED = -5,
|
||||||
|
PLAYLIST_REPLACE = -6
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -163,5 +164,6 @@ int playlist_save(struct playlist_info* playlist, char *filename);
|
||||||
int playlist_directory_tracksearch(const char* dirname, bool recurse,
|
int playlist_directory_tracksearch(const char* dirname, bool recurse,
|
||||||
int (*callback)(char*, void*),
|
int (*callback)(char*, void*),
|
||||||
void* context);
|
void* context);
|
||||||
|
int remove_all_tracks(struct playlist_info *playlist);
|
||||||
|
|
||||||
#endif /* __PLAYLIST_H__ */
|
#endif /* __PLAYLIST_H__ */
|
||||||
|
|
|
@ -1468,6 +1468,12 @@ static bool insert_all_playlist(struct tree_context *c, int position, bool queue
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (position == PLAYLIST_REPLACE)
|
||||||
|
{
|
||||||
|
if (remove_all_tracks(NULL) == 0)
|
||||||
|
position = PLAYLIST_INSERT_LAST;
|
||||||
|
else return -1; }
|
||||||
|
|
||||||
if (position == PLAYLIST_INSERT_FIRST)
|
if (position == PLAYLIST_INSERT_FIRST)
|
||||||
{
|
{
|
||||||
from = c->filesindir - 1;
|
from = c->filesindir - 1;
|
||||||
|
|
|
@ -256,3 +256,4 @@ Robert Carboneau
|
||||||
Ye Wei
|
Ye Wei
|
||||||
Bryan Childs
|
Bryan Childs
|
||||||
Mike Schmitt
|
Mike Schmitt
|
||||||
|
Chris Taylor
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue