mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 20:27:23 +00:00
player: clamp display time to known time range on seeking
During seeking, and there is momemtarily no new data available yet, the
player will display the seek target as current time. Clamp this time to
the known time range as implied by the start time and the duration of
the file.
This improves behavior especially when seeking in audio files, for which
this for some reason triggers rather often. There were some users
complaining about this.
This makes behavior worse for files with timestamp resets, or
incorrectly reported duration. (The latter is relatively common,
e.g. libavformat shortcomings, or incomplete files.)
(cherry picked from commit 0ff93a8357
)
This commit is contained in:
parent
2a6b10c9ca
commit
0126999cde
@ -382,6 +382,13 @@ double get_playback_time(struct MPContext *mpctx)
|
||||
{
|
||||
double cur = get_current_time(mpctx);
|
||||
double start = get_start_time(mpctx);
|
||||
// During seeking, the time corresponds to the last seek time - apply some
|
||||
// cosmetics to it.
|
||||
if (mpctx->playback_pts == MP_NOPTS_VALUE) {
|
||||
double length = get_time_length(mpctx);
|
||||
if (length >= 0)
|
||||
cur = MPCLAMP(cur, start, start + length);
|
||||
}
|
||||
return cur >= start ? cur - start : cur;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user