player: add append-play flag to loadlist

Closes #5664.
This commit is contained in:
Guido Cella 2021-06-26 17:36:06 +02:00 committed by Dudemanguy
parent d2dd4cacb8
commit b3fccf0803
2 changed files with 10 additions and 3 deletions

View File

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

View File

@ -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,