apps: Add "keep current track when replacing playlist" setting

Add a setting that makes Play and Play Shuffled in the playlist
context menu leave the current song (if any) playing when they
replace the playlist. Default to on, since this was the behavior
of the old "Clear List & Play Next" option.

Change-Id: I1340aed5c28bb3244e36d0953b3308ae59681c97
This commit is contained in:
Aidan MacDonald 2022-04-22 19:26:37 +01:00
parent 70087fb9f3
commit d20071def0
7 changed files with 45 additions and 5 deletions

View file

@ -16354,3 +16354,17 @@
*: "Play Shuffled"
</voice>
</phrase>
<phrase>
id: LANG_KEEP_CURRENT_TRACK_ON_REPLACE
desc: used in the playlist settings menu
user: core
<source>
*: "Keep Current Track When Replacing Playlist"
</source>
<dest>
*: "Keep Current Track When Replacing Playlist"
</dest>
<voice>
*: "Keep Current Track When Replacing Playlist"
</voice>
</phrase>

View file

@ -169,12 +169,17 @@ MAKE_MENU(viewer_settings_menu, ID2P(LANG_PLAYLISTVIEWER_SETTINGS),
/* Current Playlist submenu */
MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL);
MENUITEM_SETTING(keep_current_track_on_replace, &global_settings.keep_current_track_on_replace_playlist, NULL);
MENUITEM_SETTING(show_shuffled_adding_options, &global_settings.show_shuffled_adding_options, NULL);
MENUITEM_SETTING(show_queue_options, &global_settings.show_queue_options, NULL);
MENUITEM_SETTING(playlist_reload_after_save, &global_settings.playlist_reload_after_save, NULL);
MAKE_MENU(currentplaylist_settings_menu, ID2P(LANG_CURRENT_PLAYLIST),
NULL, Icon_Playlist,
&warn_on_erase, &show_shuffled_adding_options, &show_queue_options, &playlist_reload_after_save);
&warn_on_erase,
&keep_current_track_on_replace,
&show_shuffled_adding_options,
&show_queue_options,
&playlist_reload_after_save);
MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL,
Icon_Playlist,

View file

@ -504,8 +504,8 @@ static int add_to_playlist(void* arg)
{
struct add_to_pl_param* param = arg;
int position = param->position;
bool new_playlist = param->replace ? true : false;
bool queue = param->queue ? true : false;
bool new_playlist = !!param->replace;
bool queue = !!param->queue;
/* warn if replacing the playlist */
if (new_playlist && !warn_on_pl_erase())
@ -519,6 +519,15 @@ static int add_to_playlist(void* arg)
splash(0, ID2P(LANG_WAIT));
if (new_playlist && global_settings.keep_current_track_on_replace_playlist)
{
if (audio_status() & AUDIO_STATUS_PLAY)
{
playlist_remove_all_tracks(NULL);
new_playlist = false;
}
}
if (new_playlist)
playlist_create(NULL, NULL);

View file

@ -607,6 +607,7 @@ struct user_settings
bool fade_on_stop; /* fade on pause/unpause/stop */
bool playlist_shuffle;
bool warnon_erase_dynplaylist; /* warn when erasing dynamic playlist */
bool keep_current_track_on_replace_playlist;
bool show_shuffled_adding_options; /* whether to display options for adding shuffled tracks to dynamic playlist */
int show_queue_options; /* how and whether to display options to queue tracks */
#ifdef HAVE_ALBUMART

View file

@ -1753,9 +1753,11 @@ const struct settings_list settings[] = {
ID2P(LANG_CODEPAGE_JAPANESE),
ID2P(LANG_CODEPAGE_SIMPLIFIED), ID2P(LANG_CODEPAGE_KOREAN),
ID2P(LANG_CODEPAGE_TRADITIONAL), ID2P(LANG_CODEPAGE_UTF8)),
OFFON_SETTING(0, warnon_erase_dynplaylist, LANG_WARN_ERASEDYNPLAYLIST_MENU,
true, "warn when erasing dynamic playlist",NULL),
OFFON_SETTING(0, keep_current_track_on_replace_playlist, LANG_KEEP_CURRENT_TRACK_ON_REPLACE,
true, "keep current track when replacing playlist",NULL),
OFFON_SETTING(0, show_shuffled_adding_options, LANG_SHOW_SHUFFLED_ADDING_OPTIONS, true,
"show shuffled adding options", NULL),
CHOICE_SETTING(0, show_queue_options, LANG_SHOW_QUEUE_OPTIONS, 1,

View file

@ -31,6 +31,12 @@ related to playlists.
If set to \setting{Yes}, Rockbox will provide a warning if the user attempts to
take an action that will cause Rockbox to erase the current dynamic playlist.
\item[Keep Current Track When Replacing Playlist.]
If set to \setting{Yes}, then \setting{Play} and \setting{Play Shuffled} in
the \setting{Current Playlist submenu} will allow the current track to finish
playing before the new tracks play. If set to \setting{No}, the current
track will be interrupted and new tracks will start playing immediately.
\item[Show Shuffled Adding Options.]
If set to \setting{No}, Rockbox will not offer to add shuffled tracks
in the \setting{Current Playlist submenu}.

View file

@ -118,7 +118,10 @@ following two options will achieve that effect.
\begin{description}
\item [Play.] Replace all entries in the dynamic playlist with the selected
tracks and start playing the new playlist immediately.
tracks. If \setting{Keep Current Track When Replacing Playlist} is set to
\setting{Yes}, the new tracks will play after the current track finishes
playing; if no track is playing or the setting is \setting{No}, the new
tracks will begin playing immediately.
\item [Play Shuffled.] Similar, except the tracks will be added to the new
playlist in random order.