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 --- DOCS/man/en/input.rst | 1 + mpvcore/player/command.c | 30 ++++++++++++++++++++++++++---- mpvcore/player/lua/osc.lua | 4 ++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index 273a0dae7c..7d41c08ca2 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -534,6 +534,7 @@ Name W Comment ``ratio-pos`` x position in current file (0.0-1.0) ``time-pos`` x position in current file in seconds ``time-remaining`` estimated remaining length of the file in seconds +``playtime-remaining`` ``time-remaining`` scaled by the the current ``speed`` ``chapter`` x current chapter number ``edition`` x current MKV edition number ``titles`` number of DVD titles 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), diff --git a/mpvcore/player/lua/osc.lua b/mpvcore/player/lua/osc.lua index f105d10a9c..d1dbf3e8b4 100644 --- a/mpvcore/player/lua/osc.lua +++ b/mpvcore/player/lua/osc.lua @@ -1020,9 +1020,9 @@ function osc_init() local contentF = function (ass) if state.rightTC_trem == true then if state.tc_ms then - ass:append("-" .. mp.property_get_string("time-remaining/full")) + ass:append("-" .. mp.property_get_string("playtime-remaining/full")) else - ass:append("-" .. mp.property_get_string("time-remaining")) + ass:append("-" .. mp.property_get_string("playtime-remaining")) end else if state.tc_ms then -- cgit v1.2.3