diff options
Diffstat (limited to 'mpvcore')
-rw-r--r-- | mpvcore/player/command.c | 30 | ||||
-rw-r--r-- | mpvcore/player/lua/osc.lua | 4 |
2 files changed, 28 insertions, 6 deletions
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 |