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
This commit is contained in:
Christian Soffke 2021-03-15 23:29:24 +01:00 committed by Solomon Peachy
parent 46085c8978
commit 576b56b35a
3 changed files with 40 additions and 17 deletions

View file

@ -15674,3 +15674,17 @@
*: "In Submenu"
</voice>
</phrase>
<phrase>
id: LANG_CLEAR_LIST_AND_PLAY_SHUFFLED
desc: in onplay menu. Replace current playlist with selected tracks in random order.
user: core
<source>
*: "Clear List & Play Shuffled"
</source>
<dest>
*: "Clear List & Play Shuffled"
</dest>
<voice>
*: "Clear List & Play Shuffled"
</voice>
</phrase>

View file

@ -481,14 +481,10 @@ 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[] = {
ID2P(LANG_RECURSE_DIRECTORY_QUESTION),
@ -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;

View file

@ -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 its 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.