diff options
author | wm4 <wm4@nowhere> | 2013-05-10 15:20:40 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-05-10 15:20:40 +0200 |
commit | 139bc5ce0931b2d2bf096c1f2f90651fd15fa977 (patch) | |
tree | 4f9132c9f024f8eba82c6818c7d5d8d0600a58b1 /core | |
parent | 62786c0c91304aab720cf52674868c52a5b76f72 (diff) | |
download | mpv-139bc5ce0931b2d2bf096c1f2f90651fd15fa977.tar.bz2 mpv-139bc5ce0931b2d2bf096c1f2f90651fd15fa977.tar.xz |
command: add time-remaining property
Diffstat (limited to 'core')
-rw-r--r-- | core/command.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/command.c b/core/command.c index aea8fb2017..d9788084db 100644 --- a/core/command.c +++ b/core/command.c @@ -328,6 +328,19 @@ static int mp_property_time_pos(m_option_t *prop, int action, return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_remaining(m_option_t *prop, int action, + void *arg, MPContext *mpctx) +{ + double len = get_time_length(mpctx); + double pos = get_current_time(mpctx); + double start = get_start_time(mpctx); + + if (!(int)len) + return M_PROPERTY_UNAVAILABLE; + + return m_property_double_ro(prop, action, arg, len - (pos - start)); +} + /// Current chapter (RW) static int mp_property_chapter(m_option_t *prop, int action, void *arg, MPContext *mpctx) @@ -1373,6 +1386,7 @@ static const m_option_t mp_properties[] = { M_OPT_RANGE, 0, 100, NULL }, { "time-pos", mp_property_time_pos, CONF_TYPE_TIME, M_OPT_MIN, 0, 0, NULL }, + { "time-remaining", mp_property_remaining, CONF_TYPE_TIME }, { "chapter", mp_property_chapter, CONF_TYPE_INT, M_OPT_MIN, 0, 0, NULL }, M_OPTION_PROPERTY_CUSTOM("edition", mp_property_edition), |