mirror of
https://github.com/mpv-player/mpv
synced 2025-01-31 12:11:52 +00:00
command: extend revert_seek command
"revert_seek mark" basically forces the seekback point. It's basically a one-way bookmark.
This commit is contained in:
parent
649e337f4d
commit
c721948efe
@ -109,11 +109,20 @@ List of Input Commands
|
||||
keyframes
|
||||
Always restart playback at keyframe boundaries (fast).
|
||||
|
||||
``revert_seek``
|
||||
``revert_seek [mode]``
|
||||
Undoes the ``seek`` command, and some other commands that seek (but not
|
||||
necessarily all of them). Calling this command once will jump to the
|
||||
playback position before the seek. Calling it a second time undoes the
|
||||
``revert_seek`` command itself.
|
||||
``revert_seek`` command itself. This only works within a single file.
|
||||
|
||||
The first argument is optional, and can change the behavior:
|
||||
|
||||
mark
|
||||
Mark the current time position. The next normal ``revert_seek`` command
|
||||
will seek back to this point, no matter how many seeks happened since
|
||||
last time.
|
||||
|
||||
Using it without any arguments gives you the default behavior.
|
||||
|
||||
``frame_step``
|
||||
Play one frame, then pause. Does nothing with audio-only playback.
|
||||
|
@ -69,7 +69,9 @@ const struct mp_cmd_def mp_cmds[] = {
|
||||
},
|
||||
.allow_auto_repeat = true,
|
||||
},
|
||||
{ MP_CMD_REVERT_SEEK, "revert_seek", },
|
||||
{ MP_CMD_REVERT_SEEK, "revert_seek", {
|
||||
OARG_CHOICE(0, ({"-", 0}, {"mark", 1})),
|
||||
}},
|
||||
{ MP_CMD_QUIT, "quit", { OARG_INT(0) } },
|
||||
{ MP_CMD_QUIT_WATCH_LATER, "quit_watch_later", { OARG_INT(0) } },
|
||||
{ MP_CMD_STOP, "stop", },
|
||||
|
@ -76,6 +76,7 @@ struct command_ctx {
|
||||
|
||||
double last_seek_time;
|
||||
double last_seek_pts;
|
||||
double marked_pts;
|
||||
|
||||
double prev_pts;
|
||||
|
||||
@ -4054,8 +4055,13 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
||||
if (!mpctx->num_sources)
|
||||
return -1;
|
||||
double oldpts = cmdctx->last_seek_pts;
|
||||
if (oldpts != MP_NOPTS_VALUE) {
|
||||
if (cmdctx->marked_pts != MP_NOPTS_VALUE)
|
||||
oldpts = cmdctx->marked_pts;
|
||||
if (cmd->args[0].v.i == 1) {
|
||||
cmdctx->marked_pts = get_current_time(mpctx);
|
||||
} else if (oldpts != MP_NOPTS_VALUE) {
|
||||
cmdctx->last_seek_pts = get_current_time(mpctx);
|
||||
cmdctx->marked_pts = MP_NOPTS_VALUE;
|
||||
queue_seek(mpctx, MPSEEK_ABSOLUTE, oldpts, 1, false);
|
||||
set_osd_function(mpctx, OSD_REW);
|
||||
if (bar_osd)
|
||||
@ -4685,8 +4691,10 @@ static void command_event(struct MPContext *mpctx, int event, void *arg)
|
||||
struct command_ctx *ctx = mpctx->command_ctx;
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
|
||||
if (event == MPV_EVENT_START_FILE)
|
||||
if (event == MPV_EVENT_START_FILE) {
|
||||
ctx->last_seek_pts = MP_NOPTS_VALUE;
|
||||
ctx->marked_pts = MP_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
if (event == MPV_EVENT_TICK) {
|
||||
double now =
|
||||
|
Loading…
Reference in New Issue
Block a user