summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivek Jain <viveksjain@gmail.com>2013-12-16 22:55:36 +0800
committerwm4 <wm4@nowhere>2013-12-16 20:07:50 +0100
commit908dfa7949fb7666ac84513189448d96ea0e4be4 (patch)
treebaf56a27595a30350e066797ed3b75e214c7e89a
parente51808ea22f80a23f66db41971456b552c8a93f3 (diff)
downloadmpv-908dfa7949fb7666ac84513189448d96ea0e4be4.tar.bz2
mpv-908dfa7949fb7666ac84513189448d96ea0e4be4.tar.xz
command: scale osd’s time remaining by the current speed
Signed-off-by: wm4 <wm4@nowhere>
-rw-r--r--DOCS/man/en/input.rst1
-rw-r--r--mpvcore/player/command.c30
-rw-r--r--mpvcore/player/lua/osc.lua4
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