From 908dfa7949fb7666ac84513189448d96ea0e4be4 Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Mon, 16 Dec 2013 22:55:36 +0800 Subject: =?UTF-8?q?command:=20scale=20osd=E2=80=99s=20time=20remaining=20b?= =?UTF-8?q?y=20the=20current=20speed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wm4 --- mpvcore/player/command.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'mpvcore/player/command.c') diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c index 8849e76a4e..1b8ae9c95b 100644 --- a/mpvcore/player/command.c +++ b/mpvcore/player/command.c @@ -382,17 +382,38 @@ static int mp_property_time_pos(m_option_t *prop, int action, return property_time(prop, action, arg, get_current_time(mpctx)); } -static int mp_property_remaining(m_option_t *prop, int action, - void *arg, MPContext *mpctx) +static double time_remaining(MPContext *mpctx, double *len) { - double len = get_time_length(mpctx); + *len = get_time_length(mpctx); double pos = get_current_time(mpctx); double start = get_start_time(mpctx); + return *len - (pos - start); +} + +static int mp_property_remaining(m_option_t *prop, int action, + void *arg, MPContext *mpctx) +{ + double len; + double remaining = time_remaining(mpctx, &len); + + if (!(int)len) + return M_PROPERTY_UNAVAILABLE; + + return property_time(prop, action, arg, remaining); +} + +static int mp_property_playtime_remaining(m_option_t *prop, int action, + void *arg, MPContext *mpctx) +{ + double len; + double remaining = time_remaining(mpctx, &len); + if (!(int)len) return M_PROPERTY_UNAVAILABLE; - return property_time(prop, action, arg, len - (pos - start)); + double speed = mpctx->opts->playback_speed; + return property_time(prop, action, arg, remaining / speed); } /// Current chapter (RW) @@ -1881,6 +1902,7 @@ static const m_option_t mp_properties[] = { { "time-pos", mp_property_time_pos, CONF_TYPE_TIME, M_OPT_MIN, 0, 0, NULL }, { "time-remaining", mp_property_remaining, CONF_TYPE_TIME }, + { "playtime-remaining", mp_property_playtime_remaining, CONF_TYPE_TIME }, { "chapter", mp_property_chapter, CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL }, M_OPTION_PROPERTY_CUSTOM("edition", mp_property_edition), -- cgit v1.2.3