mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
df5706f156
commit
93b712fa8a
|
@ -226,6 +226,15 @@ List of Input Commands
|
||||||
``<skip>`` subtitle events is displayed. ``<skip>`` can be negative to step
|
``<skip>`` subtitle events is displayed. ``<skip>`` can be negative to step
|
||||||
backwards.
|
backwards.
|
||||||
|
|
||||||
|
``sub_seek <skip>``
|
||||||
|
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 [<level>]``
|
``osd [<level>]``
|
||||||
Toggle OSD level. If ``<level>`` is specified, set the OSD mode
|
Toggle OSD level. If ``<level>`` is specified, set the OSD mode
|
||||||
(see ``--osd-level`` for valid values).
|
(see ``--osd-level`` for valid values).
|
||||||
|
|
|
@ -2211,6 +2211,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
bool auto_osd = cmd->on_osd == MP_ON_OSD_AUTO;
|
bool auto_osd = cmd->on_osd == MP_ON_OSD_AUTO;
|
||||||
bool msg_osd = auto_osd || (cmd->on_osd & MP_ON_OSD_MSG);
|
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 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;
|
int osdl = msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
|
||||||
|
|
||||||
if (!cmd->raw_args) {
|
if (!cmd->raw_args) {
|
||||||
|
@ -2243,7 +2244,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
}
|
}
|
||||||
if (bar_osd)
|
if (bar_osd)
|
||||||
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
|
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;
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2349,16 +2350,25 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
case MP_CMD_SUB_STEP:
|
case MP_CMD_SUB_STEP:
|
||||||
|
case MP_CMD_SUB_SEEK:
|
||||||
if (mpctx->osd->dec_sub) {
|
if (mpctx->osd->dec_sub) {
|
||||||
double a[2];
|
double a[2];
|
||||||
a[0] = mpctx->video_pts - mpctx->osd->video_offset + opts->sub_delay;
|
a[0] = mpctx->video_pts - mpctx->osd->video_offset + opts->sub_delay;
|
||||||
a[1] = cmd->args[0].v.i;
|
a[1] = cmd->args[0].v.i;
|
||||||
if (sub_control(mpctx->osd->dec_sub, SD_CTRL_SUB_STEP, a) > 0) {
|
if (sub_control(mpctx->osd->dec_sub, SD_CTRL_SUB_STEP, a) > 0) {
|
||||||
opts->sub_delay += a[0];
|
if (cmd->id == MP_CMD_SUB_STEP) {
|
||||||
|
opts->sub_delay += a[0];
|
||||||
osd_changed_all(mpctx->osd);
|
osd_changed_all(mpctx->osd);
|
||||||
set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, osdl, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, osdl, osd_duration,
|
||||||
"Sub delay: %d ms", ROUND(opts->sub_delay * 1000));
|
"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;
|
break;
|
||||||
|
|
|
@ -157,6 +157,7 @@ static const mp_cmd_t mp_cmds[] = {
|
||||||
{"force", 1}, {"1", 1})),
|
{"force", 1}, {"1", 1})),
|
||||||
}},
|
}},
|
||||||
{ MP_CMD_SUB_STEP, "sub_step", { ARG_INT } },
|
{ 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_OSD, "osd", { OARG_INT(-1) } },
|
||||||
{ MP_CMD_PRINT_TEXT, "print_text", { ARG_STRING } },
|
{ MP_CMD_PRINT_TEXT, "print_text", { ARG_STRING } },
|
||||||
{ MP_CMD_SHOW_TEXT, "show_text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) } },
|
{ MP_CMD_SHOW_TEXT, "show_text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) } },
|
||||||
|
|
|
@ -43,6 +43,7 @@ enum mp_command_type {
|
||||||
MP_CMD_PLAYLIST_REMOVE,
|
MP_CMD_PLAYLIST_REMOVE,
|
||||||
MP_CMD_PLAYLIST_MOVE,
|
MP_CMD_PLAYLIST_MOVE,
|
||||||
MP_CMD_SUB_STEP,
|
MP_CMD_SUB_STEP,
|
||||||
|
MP_CMD_SUB_SEEK,
|
||||||
MP_CMD_TV_SET_CHANNEL,
|
MP_CMD_TV_SET_CHANNEL,
|
||||||
MP_CMD_TV_LAST_CHANNEL,
|
MP_CMD_TV_LAST_CHANNEL,
|
||||||
MP_CMD_TV_SET_FREQ,
|
MP_CMD_TV_SET_FREQ,
|
||||||
|
|
Loading…
Reference in New Issue