1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-07 23:51:49 +00:00

player: don't show "0%" percentage in infinite streams

This commit is contained in:
wm4 2014-12-20 17:31:58 +01:00
parent a69f168dff
commit 7d43a7ea84
2 changed files with 9 additions and 4 deletions

View File

@ -576,10 +576,14 @@ static int mp_property_percent_pos(void *ctx, struct m_property *prop,
.max = 100,
};
return M_PROPERTY_OK;
case M_PROPERTY_PRINT:
*(char **)arg = talloc_asprintf(NULL, "%d", get_percent_pos(mpctx));
case M_PROPERTY_PRINT: {
int pos = get_percent_pos(mpctx);
if (pos < 0)
return M_PROPERTY_UNAVAILABLE;
*(char **)arg = talloc_asprintf(NULL, "%d", pos);
return M_PROPERTY_OK;
}
}
return M_PROPERTY_NOT_IMPLEMENTED;
}

View File

@ -422,10 +422,11 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range)
return ans;
}
// 0-100, -1 if unknown
int get_percent_pos(struct MPContext *mpctx)
{
int pos = get_current_pos_ratio(mpctx, false) * 100;
return MPCLAMP(pos, 0, 100);
double pos = get_current_pos_ratio(mpctx, false);
return pos < 0 ? -1 : pos * 100;
}
// -2 is no chapters, -1 is before first chapter