mirror of
https://github.com/mpv-player/mpv
synced 2025-04-17 20:58:20 +00:00
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).
This commit is contained in:
parent
3a5cbf3907
commit
ff531b71e3
@ -95,7 +95,7 @@ List of Input Commands
|
|||||||
relative (default)
|
relative (default)
|
||||||
Seek relative to current position (a negative value seeks backwards).
|
Seek relative to current position (a negative value seeks backwards).
|
||||||
absolute
|
absolute
|
||||||
Seek to a given time.
|
Seek to a given time (a negative value starts from the end of the file).
|
||||||
absolute-percent
|
absolute-percent
|
||||||
Seek to a given percent position.
|
Seek to a given percent position.
|
||||||
relative-percent
|
relative-percent
|
||||||
|
@ -930,7 +930,9 @@ static int mp_property_chapter(void *ctx, struct m_property *prop,
|
|||||||
if (current_chapter_start != MP_NOPTS_VALUE &&
|
if (current_chapter_start != MP_NOPTS_VALUE &&
|
||||||
get_current_time(mpctx) - current_chapter_start >
|
get_current_time(mpctx) - current_chapter_start >
|
||||||
mpctx->opts->chapter_seek_threshold)
|
mpctx->opts->chapter_seek_threshold)
|
||||||
|
{
|
||||||
step_all++;
|
step_all++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else // Absolute set
|
} else // Absolute set
|
||||||
step_all = *(int *)arg - chapter;
|
step_all = *(int *)arg - chapter;
|
||||||
@ -4815,6 +4817,13 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: { // Absolute seek to a timestamp in seconds
|
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);
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, v, precision, MPSEEK_FLAG_DELAY);
|
||||||
set_osd_function(mpctx,
|
set_osd_function(mpctx,
|
||||||
v > get_current_time(mpctx) ? OSD_FFW : OSD_REW);
|
v > get_current_time(mpctx) ? OSD_FFW : OSD_REW);
|
||||||
|
Loading…
Reference in New Issue
Block a user