diff options
author | wm4 <wm4@nowhere> | 2015-01-14 22:14:20 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-14 22:14:20 +0100 |
commit | 1a522f2976004b8896d71e71446ae04723df3cec (patch) | |
tree | 0a791ed091eef0c49ccfeaaaff0af1d3ff008d3e | |
parent | 3cb2add636b776d7707ea0d0d5d6c6593c577207 (diff) | |
download | mpv-1a522f2976004b8896d71e71446ae04723df3cec.tar.bz2 mpv-1a522f2976004b8896d71e71446ae04723df3cec.tar.xz |
player: fallback to seek time for percent-pos property
The percent-pos property normally goes by time, except for file formats
like .ts or .ogg, where you can't trust the timestamps and duration info
to compute the position in the overall files. These use the byte
position and size instead.
When the file position was unavailable (e.g. due to an ongoing seek),
the percent-pos was unknown. Change it to use the time position instead.
In most cases, it's actually accurate enough, and the temporary
unavailability of the property can be annoying, e.g. on the terminal
status line.
-rw-r--r-- | player/playloop.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/player/playloop.c b/player/playloop.c index fc55b9bf05..cabdb4e441 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -405,9 +405,9 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range) len = endpos - startpos; } double pos = get_current_time(mpctx); - if (len > 0 && !demuxer->ts_resets_possible) { + if (len > 0) ans = MPCLAMP((pos - start) / len, 0, 1); - } else { + if (ans < 0 || demuxer->ts_resets_possible) { int64_t size; if (demux_stream_control(demuxer, STREAM_CTRL_GET_SIZE, &size) > 0) { if (size > 0 && demuxer->filepos >= 0) |