From d20071def023b9ddac34559951871e037bd59785 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Fri, 22 Apr 2022 19:26:37 +0100 Subject: 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/onplay.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'apps/onplay.c') 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); -- cgit v1.2.3