mirror of
https://github.com/mpv-player/mpv
synced 2025-03-01 03:40:43 +00:00
command: add time-remaining property
This commit is contained in:
parent
62786c0c91
commit
139bc5ce09
@ -284,6 +284,7 @@ length length of the current file in seconds
|
||||
avsync last A/V synchronization difference
|
||||
percent-pos x position in current file (0-100)
|
||||
time-pos x position in current file in seconds
|
||||
time-remaining estimated remaining length of the file in seconds
|
||||
chapter x current chapter number
|
||||
edition x current MKV edition number
|
||||
titles number of DVD titles
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user