From 93b712fa8ab56217da2e8a5317891f4d0df1838f Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 2 Oct 2013 21:05:04 +0200 Subject: command: add sub_seek input command Essentially reuses the sub_step command, and is subject to the same restrictions. Seems to behave a bit strange sometimes, but generally works. --- DOCS/man/en/input.rst | 9 +++++++++ mpvcore/command.c | 22 ++++++++++++++++------ mpvcore/input/input.c | 1 + mpvcore/input/input.h | 1 + 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index 362e8a4cf8..558bb39fbf 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -226,6 +226,15 @@ List of Input Commands ```` subtitle events is displayed. ```` can be negative to step backwards. +``sub_seek `` + Seek to the next (skip set to 1) or the previous (skip set to -1) subtitle. + This is similar to ``sub_step``, except that it seeks video and audio + instead of adjusting the subtitle delay. + + Like with ``sub_step``, this works with external text subtitles only. For + embedded text subtitles (like with Matroska), this works only with subtitle + events that have already been displayed. + ``osd []`` Toggle OSD level. If ```` is specified, set the OSD mode (see ``--osd-level`` for valid values). diff --git a/mpvcore/command.c b/mpvcore/command.c index a18d5620a1..3dc813673b 100644 --- a/mpvcore/command.c +++ b/mpvcore/command.c @@ -2211,6 +2211,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) bool auto_osd = cmd->on_osd == MP_ON_OSD_AUTO; bool msg_osd = auto_osd || (cmd->on_osd & MP_ON_OSD_MSG); bool bar_osd = auto_osd || (cmd->on_osd & MP_ON_OSD_BAR); + bool msg_or_nobar_osd = msg_osd && !(auto_osd && opts->osd_bar_visible); int osdl = msg_osd ? 1 : OSD_LEVEL_INVISIBLE; if (!cmd->raw_args) { @@ -2243,7 +2244,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) } if (bar_osd) mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR; - if (msg_osd && !(auto_osd && opts->osd_bar_visible)) + if (msg_or_nobar_osd) mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT; break; } @@ -2349,16 +2350,25 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) } case MP_CMD_SUB_STEP: + case MP_CMD_SUB_SEEK: if (mpctx->osd->dec_sub) { double a[2]; a[0] = mpctx->video_pts - mpctx->osd->video_offset + opts->sub_delay; a[1] = cmd->args[0].v.i; if (sub_control(mpctx->osd->dec_sub, SD_CTRL_SUB_STEP, a) > 0) { - opts->sub_delay += a[0]; - - osd_changed_all(mpctx->osd); - set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, osdl, osd_duration, - "Sub delay: %d ms", ROUND(opts->sub_delay * 1000)); + if (cmd->id == MP_CMD_SUB_STEP) { + opts->sub_delay += a[0]; + osd_changed_all(mpctx->osd); + set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, osdl, osd_duration, + "Sub delay: %d ms", ROUND(opts->sub_delay * 1000)); + } else { + queue_seek(mpctx, MPSEEK_RELATIVE, a[0], 1); + set_osd_function(mpctx, (a[0] > 0) ? OSD_FFW : OSD_REW); + if (bar_osd) + mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR; + if (msg_or_nobar_osd) + mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT; + } } } break; diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c index d318a0d7c5..c78447c4bf 100644 --- a/mpvcore/input/input.c +++ b/mpvcore/input/input.c @@ -157,6 +157,7 @@ static const mp_cmd_t mp_cmds[] = { {"force", 1}, {"1", 1})), }}, { MP_CMD_SUB_STEP, "sub_step", { ARG_INT } }, + { MP_CMD_SUB_SEEK, "sub_seek", { ARG_INT } }, { MP_CMD_OSD, "osd", { OARG_INT(-1) } }, { MP_CMD_PRINT_TEXT, "print_text", { ARG_STRING } }, { MP_CMD_SHOW_TEXT, "show_text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) } }, diff --git a/mpvcore/input/input.h b/mpvcore/input/input.h index 5166e884b4..33c269c1a7 100644 --- a/mpvcore/input/input.h +++ b/mpvcore/input/input.h @@ -43,6 +43,7 @@ enum mp_command_type { MP_CMD_PLAYLIST_REMOVE, MP_CMD_PLAYLIST_MOVE, MP_CMD_SUB_STEP, + MP_CMD_SUB_SEEK, MP_CMD_TV_SET_CHANNEL, MP_CMD_TV_LAST_CHANNEL, MP_CMD_TV_SET_FREQ, -- cgit v1.2.3