summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido Cella <guido@guidocella.xyz>2021-06-26 17:36:06 +0200
committerDudemanguy <random342@airmail.cc>2021-07-06 15:46:45 +0000
commitb3fccf080369730e1b4d6a3435c90124a74566f7 (patch)
treed6aad65f1695fdd54f4e5e323326712e8ed6d81f
parentd2dd4cacb804f8f95f648c6dc4b0b9481ffa9410 (diff)
downloadmpv-b3fccf080369730e1b4d6a3435c90124a74566f7.tar.bz2
mpv-b3fccf080369730e1b4d6a3435c90124a74566f7.tar.xz
player: add append-play flag to loadlist
Closes #5664.
-rw-r--r--DOCS/man/input.rst4
-rw-r--r--player/command.c9
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>
Append the new playlist at the end of the current internal playlist.
+ <append-play>
+ 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,