From b3fccf080369730e1b4d6a3435c90124a74566f7 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sat, 26 Jun 2021 17:36:06 +0200 Subject: player: add append-play flag to loadlist Closes #5664. --- DOCS/man/input.rst | 4 ++++ player/command.c | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index fcb65b7f66..6aacdb7304 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -450,6 +450,10 @@ Remember to quote string arguments in input.conf (see `Flat command syntax`_). Stop playback and replace the internal playlist with the new one. Append the new playlist at the end of the current internal playlist. + + Append the new playlist, and if nothing is currently playing, start + playback. (Always starts with the new playlist, even if the internal + playlist was not empty before running this command.) ``playlist-clear`` Clear the playlist, except the currently played file. diff --git a/player/command.c b/player/command.c index 66ef01951e..051d83b14d 100644 --- a/player/command.c +++ b/player/command.c @@ -5144,7 +5144,7 @@ static void cmd_loadlist(void *p) struct mp_cmd_ctx *cmd = p; struct MPContext *mpctx = cmd->mpctx; char *filename = cmd->args[0].v.s; - bool append = cmd->args[1].v.i; + int append = cmd->args[1].v.i; struct playlist *pl = playlist_parse_file(filename, cmd->abort->cancel, mpctx->global); @@ -5161,7 +5161,7 @@ static void cmd_loadlist(void *p) if (!new) new = playlist_get_first(mpctx->playlist); - if (!append && new) + if ((!append || (append == 2 && !mpctx->playlist->current)) && new) mp_set_playlist_entry(mpctx, new); struct mpv_node *res = &cmd->result; @@ -6217,7 +6217,10 @@ const struct mp_cmd_def mp_cmds[] = { { "loadlist", cmd_loadlist, { {"url", OPT_STRING(v.s)}, - {"flags", OPT_CHOICE(v.i, {"replace", 0}, {"append", 1}), + {"flags", OPT_CHOICE(v.i, + {"replace", 0}, + {"append", 1}, + {"append-play", 2}), .flags = MP_CMD_OPT_ARG}, }, .spawn_thread = true, -- cgit v1.2.3