diff options
author | wm4 <wm4@nowhere> | 2014-10-20 23:55:29 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-10-21 00:15:04 +0200 |
commit | 131633b4e5a378ce67ad7e04ca713097f0c01c71 (patch) | |
tree | 44f48ef4af18b7b845ab60899505640d51c88128 | |
parent | b79f291f4bb6f3f2efb24b9f03829784c17a0541 (diff) | |
download | mpv-131633b4e5a378ce67ad7e04ca713097f0c01c71.tar.bz2 mpv-131633b4e5a378ce67ad7e04ca713097f0c01c71.tar.xz |
command: extend sub_add command
-rw-r--r-- | DOCS/man/input.rst | 18 | ||||
-rw-r--r-- | input/cmd_list.c | 4 | ||||
-rw-r--r-- | player/command.c | 12 |
3 files changed, 30 insertions, 4 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 7f141262a3..4d30a3cf43 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -260,10 +260,26 @@ List of Input Commands will seek to the previous position on start. The (optional) argument is exactly as in the ``quit`` command. -``sub_add "<file>"`` +``sub_add "<file>" [<flags> [<title> [<lang>]]]`` Load the given subtitle file. It is selected as current subtitle after loading. + The ``flags`` args is one of the following values: + + <select> + + Select the subtitle immediately. + + <auto> + + Don't select the subtitle. (Or in some special situations, let the + default stream selection mechanism decide.) + + The ``title`` argument sets the track title in the UI. + + The ``lang`` argument sets the track language, and can also influence + stream selection with ``flags`` set to ``auto``. + ``sub_remove [<id>]`` Remove the given subtitle track. If the ``id`` argument is missing, remove the current track. (Works on external subtitle files only.) diff --git a/input/cmd_list.c b/input/cmd_list.c index e6329b9d89..885fc01dc4 100644 --- a/input/cmd_list.c +++ b/input/cmd_list.c @@ -89,7 +89,9 @@ const struct mp_cmd_def mp_cmds[] = { { MP_CMD_SHOW_TEXT, "show_text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) }, .allow_auto_repeat = true}, { MP_CMD_SHOW_PROGRESS, "show_progress", .allow_auto_repeat = true}, - { MP_CMD_SUB_ADD, "sub_add", { ARG_STRING } }, + { MP_CMD_SUB_ADD, "sub_add", { ARG_STRING, + OARG_CHOICE(0, ({"select", 0}, {"auto", 1})), + ARG_STRING, ARG_STRING } }, { MP_CMD_SUB_REMOVE, "sub_remove", { OARG_INT(-1) } }, { MP_CMD_SUB_RELOAD, "sub_reload", { OARG_INT(-1) } }, diff --git a/player/command.c b/player/command.c index 2e42c8079f..e4cd73131c 100644 --- a/player/command.c +++ b/player/command.c @@ -4019,8 +4019,16 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd) struct track *sub = mp_add_subtitles(mpctx, cmd->args[0].v.s); if (!sub) return -1; - mp_switch_track(mpctx, sub->type, sub); - mp_mark_user_track_selection(mpctx, 0, sub->type); + if (cmd->args[1].v.i == 0) { + mp_switch_track(mpctx, sub->type, sub); + mp_mark_user_track_selection(mpctx, 0, sub->type); + } + char *title = cmd->args[2].v.s; + if (title && title[0]) + sub->title = talloc_strdup(sub, title); + char *lang = cmd->args[3].v.s; + if (lang && lang[0]) + sub->lang = talloc_strdup(sub, lang); break; } |