command: provide per-file-options for loadfile command

Signed-off-by: wm4 <wm4@nowhere>

Closes #575. Minor changes over original pull request.
This commit is contained in:
xylosper 2014-02-22 15:28:05 +09:00 committed by wm4
parent f5c781b0d5
commit bb6b543812
3 changed files with 11 additions and 1 deletions

View File

@ -122,6 +122,7 @@ const struct mp_cmd_def mp_cmds[] = {
ARG_STRING,
OARG_CHOICE(0, ({"replace", 0}, {"0", 0},
{"append", 1}, {"1", 1})),
OPT_KEYVALUELIST(ARG(str_list), 0),
}},
{ MP_CMD_LOADLIST, "loadlist", {
ARG_STRING,

View File

@ -75,6 +75,7 @@ struct mp_cmd_arg {
float f;
double d;
char *s;
char **str_list;
void *p;
} v;
};

View File

@ -2973,7 +2973,15 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (!append)
playlist_clear(mpctx->playlist);
playlist_add(mpctx->playlist, playlist_entry_new(filename));
struct playlist_entry *entry = playlist_entry_new(filename);
if (cmd->args[2].v.str_list) {
char **pairs = cmd->args[2].v.str_list;
for (int i = 0; pairs[i] && pairs[i + 1]; i += 2) {
playlist_entry_add_param(entry, bstr0(pairs[i]),
bstr0(pairs[i + 1]));
}
}
playlist_add(mpctx->playlist, entry);
if (!append)
mp_set_playlist_entry(mpctx, mpctx->playlist->first);