summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-23 00:20:53 +0200
committerwm4 <wm4@nowhere>2014-07-23 00:20:53 +0200
commit843f5f47233956cfc03ea656c85771323bc7a1a2 (patch)
treeda64a5bd0013eb97a45c0341faebfbec0addcbd7
parent10debffc06d3a4ce923ac1062931f0afdf729824 (diff)
downloadmpv-843f5f47233956cfc03ea656c85771323bc7a1a2.tar.bz2
mpv-843f5f47233956cfc03ea656c85771323bc7a1a2.tar.xz
command: add append-play loadfile mode
"loadfile filename append-play" will now always append the file to the playlist, and if nothing is playing yet, start playback. I don't want to change the semantics of "append" mode, so a new mode is needed. Probably fixes issue #950.
-rw-r--r--DOCS/man/input.rst2
-rw-r--r--input/cmd_list.c3
-rw-r--r--player/command.c4
3 files changed, 6 insertions, 3 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index b2ca61a516..cc92eaf843 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -193,6 +193,8 @@ List of Input Commands
Stop playback of the current file, and play the new file immediately.
<append>
Append the file to the playlist.
+ <append-play>
+ Append the file, and if nothing is currently playing, start playback.
The third argument is a list of options and values which should be set
while the file is playing. It is of the form ``opt1=value1,opt2=value2,..``.
diff --git a/input/cmd_list.c b/input/cmd_list.c
index 1096e83d63..6f763c4b64 100644
--- a/input/cmd_list.c
+++ b/input/cmd_list.c
@@ -111,7 +111,8 @@ const struct mp_cmd_def mp_cmds[] = {
{ MP_CMD_LOADFILE, "loadfile", {
ARG_STRING,
OARG_CHOICE(0, ({"replace", 0}, {"0", 0},
- {"append", 1}, {"1", 1})),
+ {"append", 1}, {"1", 1},
+ {"append-play", 2})),
OPT_KEYVALUELIST(ARG(str_list), MP_CMD_OPT_ARG),
}},
{ MP_CMD_LOADLIST, "loadlist", {
diff --git a/player/command.c b/player/command.c
index af9350f39c..5e446265ae 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3597,7 +3597,7 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_LOADFILE: {
char *filename = cmd->args[0].v.s;
- bool append = cmd->args[1].v.i;
+ int append = cmd->args[1].v.i;
if (!append)
playlist_clear(mpctx->playlist);
@@ -3612,7 +3612,7 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
}
playlist_add(mpctx->playlist, entry);
- if (!append)
+ if (!append || (append == 2 && !mpctx->playlist->current))
mp_set_playlist_entry(mpctx, mpctx->playlist->first);
break;
}