diff options
author | wm4 <wm4@nowhere> | 2013-06-28 22:28:21 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-06-29 22:58:13 +0200 |
commit | d4680aaecdc8711a878d973c74e223d49cdf9da3 (patch) | |
tree | 476f5f8550fcf505bfe98b7929dd21216d06ca8c | |
parent | a6a1f4b8336c0d18c0588922da6b786b6408209f (diff) | |
download | mpv-d4680aaecdc8711a878d973c74e223d49cdf9da3.tar.bz2 mpv-d4680aaecdc8711a878d973c74e223d49cdf9da3.tar.xz |
command: make raw percent-pos property return fractions
percent-pos was an integer (0-100). Sometimes higher precision is
wanted, but the property is this way because fractional parts would
look silly with normal OSD usage. As a compromise, make percent-pos
double (i.e. includes fractional parts), but print it as integer.
So ${percent-pos} is like an integer, but not ${=percent-pos}.
-rw-r--r-- | DOCS/man/en/input.rst | 1 | ||||
-rw-r--r-- | core/command.c | 9 |
2 files changed, 7 insertions, 3 deletions
diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index cb5e57e7a2..440d1a655e 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -330,6 +330,7 @@ stream-time-pos x time position in source stream (also see time-pos) length length of the current file in seconds avsync last A/V synchronization difference percent-pos x position in current file (0-100) +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 chapter x current chapter number diff --git a/core/command.c b/core/command.c index 5a617c20f5..828bf21a08 100644 --- a/core/command.c +++ b/core/command.c @@ -322,11 +322,14 @@ static int mp_property_percent_pos(m_option_t *prop, int action, switch (action) { case M_PROPERTY_SET: ; - int pos = *(int *)arg; + double pos = *(double *)arg; queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, 0); return M_PROPERTY_OK; case M_PROPERTY_GET: - *(int *)arg = get_percent_pos(mpctx); + *(double *)arg = get_current_pos_ratio(mpctx, false) * 100.0; + return M_PROPERTY_OK; + case M_PROPERTY_PRINT: + *(char **)arg = talloc_asprintf(NULL, "%d", get_percent_pos(mpctx)); return M_PROPERTY_OK; } return M_PROPERTY_NOT_IMPLEMENTED; @@ -1623,7 +1626,7 @@ static const m_option_t mp_properties[] = { { "length", mp_property_length, CONF_TYPE_TIME, M_OPT_MIN, 0, 0, NULL }, { "avsync", mp_property_avsync, CONF_TYPE_DOUBLE }, - { "percent-pos", mp_property_percent_pos, CONF_TYPE_INT, + { "percent-pos", mp_property_percent_pos, CONF_TYPE_DOUBLE, M_OPT_RANGE, 0, 100, NULL }, { "time-pos", mp_property_time_pos, CONF_TYPE_TIME, M_OPT_MIN, 0, 0, NULL }, |