summaryrefslogtreecommitdiffstats
path: root/player/command.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/command.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/command.c')
-rw-r--r--player/command.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/player/command.c b/player/command.c
index 752a62de8f..c69e058ae2 100644
--- a/player/command.c
+++ b/player/command.c
@@ -485,9 +485,9 @@ static int mp_property_length(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- double len;
+ double len = get_time_length(mpctx);
- if ((len = get_time_length(mpctx)) <= 0)
+ if (len < 0)
return M_PROPERTY_UNAVAILABLE;
return property_time(action, arg, len);
@@ -605,7 +605,7 @@ static bool time_remaining(MPContext *mpctx, double *remaining)
*remaining = len - playback;
- return len > 0;
+ return len >= 0;
}
static int mp_property_remaining(void *ctx, struct m_property *prop,
@@ -2234,10 +2234,12 @@ static int get_frame_count(struct MPContext *mpctx)
return 0;
if (!mpctx->d_video)
return 0;
+ double len = get_time_length(mpctx);
+ double fps = mpctx->d_video->fps;
+ if (len < 0 || fps <= 0)
+ return 0;
- int frame_count = (int)(get_time_length(mpctx) * mpctx->d_video->fps);
-
- return frame_count;
+ return len * fps;
}
static int mp_property_frame_number(void *ctx, struct m_property *prop,