From d20071def023b9ddac34559951871e037bd59785 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Fri, 22 Apr 2022 19:26:37 +0100 Subject: [PATCH] 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 --- apps/lang/english.lang | 14 ++++++++++++++ apps/menus/playlist_menu.c | 7 ++++++- apps/onplay.c | 13 +++++++++++-- apps/settings.h | 1 + apps/settings_list.c | 4 +++- manual/configure_rockbox/playlist_options.tex | 6 ++++++ manual/working_with_playlists/main.tex | 5 ++++- 7 files changed, 45 insertions(+), 5 deletions(-) diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 4689660176..3b505bb9a2 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -16354,3 +16354,17 @@ *: "Play Shuffled" + + id: LANG_KEEP_CURRENT_TRACK_ON_REPLACE + desc: used in the playlist settings menu + user: core + + *: "Keep Current Track When Replacing Playlist" + + + *: "Keep Current Track When Replacing Playlist" + + + *: "Keep Current Track When Replacing Playlist" + + diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c index b84abe0b37..e1e83d4311 100644 --- a/apps/menus/playlist_menu.c +++ b/apps/menus/playlist_menu.c @@ -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, diff --git a/apps/onplay.c b/apps/onplay.c index 729fe40f0a..4ffa6deece 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -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); diff --git a/apps/settings.h b/apps/settings.h index 53d7d35cae..9af8e27e5e 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -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 diff --git a/apps/settings_list.c b/apps/settings_list.c index c2dec49499..0e39a58b1a 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -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, diff --git a/manual/configure_rockbox/playlist_options.tex b/manual/configure_rockbox/playlist_options.tex index 4f6024127e..b29842ceed 100644 --- a/manual/configure_rockbox/playlist_options.tex +++ b/manual/configure_rockbox/playlist_options.tex @@ -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}. diff --git a/manual/working_with_playlists/main.tex b/manual/working_with_playlists/main.tex index 0d1ab7ef04..8571aac61c 100644 --- a/manual/working_with_playlists/main.tex +++ b/manual/working_with_playlists/main.tex @@ -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.