diff options
author | Philip Sequeira <phsequei@gmail.com> | 2016-10-01 14:51:17 -0400 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-10-02 18:01:52 +0200 |
commit | ff531b71e3c593c6a05475fcb2510ee00ec7c9d4 (patch) | |
tree | 8535eed056dbc2ebb5f37e1be36942bfa7d0f61c /player | |
parent | 3a5cbf39072fd07f457560f25899dda442246b20 (diff) | |
download | mpv-ff531b71e3c593c6a05475fcb2510ee00ec7c9d4.tar.bz2 mpv-ff531b71e3c593c6a05475fcb2510ee00ec7c9d4.tar.xz |
command: allow absolute seeks relative to end of stream
"seek -10 absolute" will seek to 10 seconds before the end. This more or less
matches the --start option and negative seeks were otherwise useless (they just
clipped to 0).
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c index a714123558..24e79c5b98 100644 --- a/player/command.c +++ b/player/command.c @@ -930,7 +930,9 @@ static int mp_property_chapter(void *ctx, struct m_property *prop, if (current_chapter_start != MP_NOPTS_VALUE && get_current_time(mpctx) - current_chapter_start > mpctx->opts->chapter_seek_threshold) + { step_all++; + } } } else // Absolute set step_all = *(int *)arg - chapter; @@ -4815,6 +4817,13 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re break; } case 2: { // Absolute seek to a timestamp in seconds + if (v < 0) { + // Seek from end + double len = get_time_length(mpctx); + if (len < 0) + return -1; + v = MPMAX(0, len + v); + } queue_seek(mpctx, MPSEEK_ABSOLUTE, v, precision, MPSEEK_FLAG_DELAY); set_osd_function(mpctx, v > get_current_time(mpctx) ? OSD_FFW : OSD_REW); |