From 576b56b35a2bb74b77f5b399189ee6e16de9f4c9 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Mon, 15 Mar 2021 23:29:24 +0100 Subject: [PATCH] Offer function to Clear List & Play Shuffled when playback is stopped (as per multiple user requests) When playback is stopped, Rockbox will display an option to clear the current playlist and add selected tracks in random order, if Shuffled Adding options are enabled in Settings. Insert options will not be displayed anymore when playback is stopped to lessen confusion. Change-Id: I5e5819149027e63e5c6f30213e838c0d7e7de8d5 --- apps/lang/english.lang | 14 ++++++++++ apps/onplay.c | 38 +++++++++++++++----------- manual/working_with_playlists/main.tex | 5 +++- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 80a29601a0..8365e9d265 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -15673,4 +15673,18 @@ *: "In Submenu" + + + id: LANG_CLEAR_LIST_AND_PLAY_SHUFFLED + desc: in onplay menu. Replace current playlist with selected tracks in random order. + user: core + + *: "Clear List & Play Shuffled" + + + *: "Clear List & Play Shuffled" + + + *: "Clear List & Play Shuffled" + \ No newline at end of file diff --git a/apps/onplay.c b/apps/onplay.c index be92a2909a..d72f592f2e 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -481,13 +481,9 @@ static bool add_to_playlist(int position, bool queue) bool new_playlist = false; if (!(audio_status() & AUDIO_STATUS_PLAY)) { + new_playlist = true; if (position == PLAYLIST_REPLACE) - { - new_playlist = true; position = PLAYLIST_INSERT; - } - else if (global_status.resume_index == -1 || playlist_resume() == -1) - new_playlist = true; } const char *lines[] = { @@ -569,7 +565,9 @@ static bool view_playlist(void) static int playlist_insert_func(void *param) { - if (((intptr_t)param == PLAYLIST_REPLACE) && !warn_on_pl_erase()) + if (((intptr_t)param == PLAYLIST_REPLACE || + ((intptr_t)param == PLAYLIST_INSERT_SHUFFLED && !(audio_status() & AUDIO_STATUS_PLAY))) && + !warn_on_pl_erase()) return 0; add_to_playlist((intptr_t)param, false); return 0; @@ -592,7 +590,7 @@ static int treeplaylist_callback(int action, /* insert items */ MENUITEM_FUNCTION(i_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT), playlist_insert_func, (intptr_t*)PLAYLIST_INSERT, - treeplaylist_callback, Icon_Playlist); + treeplaylist_wplayback_callback, Icon_Playlist); MENUITEM_FUNCTION(i_first_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_INSERT_FIRST), playlist_insert_func, (intptr_t*)PLAYLIST_INSERT_FIRST, treeplaylist_wplayback_callback, Icon_Playlist); @@ -677,6 +675,11 @@ MENUITEM_FUNCTION(replace_pl_item, MENU_FUNC_USEPARAM, ID2P(LANG_CLEAR_LIST_AND_ playlist_insert_func, (intptr_t*)PLAYLIST_REPLACE, NULL, Icon_Playlist); +MENUITEM_FUNCTION(replace_shuf_pl_item, MENU_FUNC_USEPARAM, + ID2P(LANG_CLEAR_LIST_AND_PLAY_SHUFFLED), playlist_insert_func, + (intptr_t*)PLAYLIST_INSERT_SHUFFLED, + treeplaylist_callback, Icon_Playlist); + MAKE_ONPLAYMENU(tree_playlist_menu, ID2P(LANG_CURRENT_PLAYLIST), treeplaylist_callback, Icon_Playlist, @@ -698,7 +701,8 @@ MAKE_ONPLAYMENU(tree_playlist_menu, ID2P(LANG_CURRENT_PLAYLIST), &queue_menu, /* replace */ - &replace_pl_item + &replace_pl_item, + &replace_shuf_pl_item ); static int treeplaylist_callback(int action, const struct menu_item_ex *this_item, @@ -715,11 +719,6 @@ static int treeplaylist_callback(int action, (selected_file_attr & ATTR_DIRECTORY)) return action; } - else if (this_item == &i_pl_item && - global_status.resume_index != -1) - { - return action; - } else if ((this_item == &q_pl_item || this_item == &q_first_pl_item || this_item == &q_last_pl_item) && @@ -731,9 +730,16 @@ static int treeplaylist_callback(int action, else if (this_item == &i_shuf_pl_item) { if (global_settings.show_shuffled_adding_options && - (global_status.resume_index != -1) && - ((audio_status() & AUDIO_STATUS_PLAY) || - (selected_file_attr & ATTR_DIRECTORY) || + (audio_status() & AUDIO_STATUS_PLAY)) + { + return action; + } + } + else if (this_item == &replace_shuf_pl_item) + { + if (global_settings.show_shuffled_adding_options && + !(audio_status() & AUDIO_STATUS_PLAY) && + ((selected_file_attr & ATTR_DIRECTORY) || ((selected_file_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U))) { return action; diff --git a/manual/working_with_playlists/main.tex b/manual/working_with_playlists/main.tex index 8bc233d346..4a8a0174ab 100644 --- a/manual/working_with_playlists/main.tex +++ b/manual/working_with_playlists/main.tex @@ -95,8 +95,11 @@ have not been added yet, immediately after the currently playing track. \item [Insert Last Shuffled.] Add tracks in a random order to the end of the playlist. -\item [Clear List \& Play Next.] Replaces all tracks in the dynamic playlist. +\item [Clear List \& Play Next.] Replace all tracks in the dynamic playlist. If a track is currently playing, it is only removed once it’s finished playing. + +\item [Clear List \& Play Shuffled.] Replace dynamic playlist with selected tracks +in random order. Available, if playback is stopped. \end{description} There are also options for adding tracks only temporarily to the dynamic playlist.