summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-29 21:54:59 +0100
committerwm4 <wm4@nowhere>2014-10-29 21:54:59 +0100
commit2bb02879aa3ebdb5d4e51d8d410c929fe26d58be (patch)
treed044f19399188efd5059261475a45efc1ddf4ce7 /player/playloop.c
parent2c320fb609dde644bcfa3389e6a2664baa38ee2b (diff)
downloadmpv-2bb02879aa3ebdb5d4e51d8d410c929fe26d58be.tar.bz2
mpv-2bb02879aa3ebdb5d4e51d8d410c929fe26d58be.tar.xz
player: don't display zero duration for files with unknown duration
On OSD/terminal, just don't display the duration if unavailable. Make the "length" property unavailable if duration is unavailable.
Diffstat (limited to 'player/playloop.c')
-rw-r--r--player/playloop.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/player/playloop.c b/player/playloop.c
index 764dc05971..8a0aba2ec8 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -196,7 +196,7 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
mpctx->last_chapter_seek = -2;
if (seek.type == MPSEEK_FACTOR && !mpctx->demuxer->ts_resets_possible) {
double len = get_time_length(mpctx);
- if (len > 0) {
+ if (len >= 0) {
seek.amount = seek.amount * len + get_start_time(mpctx);
seek.type = MPSEEK_ABSOLUTE;
}
@@ -359,11 +359,12 @@ void execute_queued_seek(struct MPContext *mpctx)
}
}
+// -1 if unknown
double get_time_length(struct MPContext *mpctx)
{
struct demuxer *demuxer = mpctx->demuxer;
if (!demuxer)
- return 0;
+ return -1;
if (mpctx->timeline)
return mpctx->timeline[mpctx->num_timeline_parts].start;
@@ -372,8 +373,7 @@ double get_time_length(struct MPContext *mpctx)
if (len >= 0)
return len;
- // Unknown
- return 0;
+ return -1; // unknown
}
/* If there are timestamps from stream level then use those (for example
@@ -410,8 +410,8 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range)
if (use_range) {
double startpos = rel_time_to_abs(mpctx, mpctx->opts->play_start);
double endpos = get_play_end_pts(mpctx);
- if (endpos == MP_NOPTS_VALUE || endpos > start + len)
- endpos = start + len;
+ if (endpos == MP_NOPTS_VALUE || endpos > start + MPMAX(0, len))
+ endpos = start + MPMAX(0, len);
if (startpos == MP_NOPTS_VALUE || startpos < start)
startpos = start;
if (endpos < startpos)
@@ -420,7 +420,7 @@ 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 && !demuxer->ts_resets_possible) {
ans = MPCLAMP((pos - start) / len, 0, 1);
} else {
int64_t size;