mirror of https://github.com/mpv-player/mpv
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}.
This commit is contained in:
parent
a6a1f4b833
commit
d4680aaecd
|
@ -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
|
length length of the current file in seconds
|
||||||
avsync last A/V synchronization difference
|
avsync last A/V synchronization difference
|
||||||
percent-pos x position in current file (0-100)
|
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-pos x position in current file in seconds
|
||||||
time-remaining estimated remaining length of the file in seconds
|
time-remaining estimated remaining length of the file in seconds
|
||||||
chapter x current chapter number
|
chapter x current chapter number
|
||||||
|
|
|
@ -322,11 +322,14 @@ static int mp_property_percent_pos(m_option_t *prop, int action,
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case M_PROPERTY_SET: ;
|
case M_PROPERTY_SET: ;
|
||||||
int pos = *(int *)arg;
|
double pos = *(double *)arg;
|
||||||
queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, 0);
|
queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, 0);
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
case M_PROPERTY_GET:
|
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_OK;
|
||||||
}
|
}
|
||||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
|
@ -1623,7 +1626,7 @@ static const m_option_t mp_properties[] = {
|
||||||
{ "length", mp_property_length, CONF_TYPE_TIME,
|
{ "length", mp_property_length, CONF_TYPE_TIME,
|
||||||
M_OPT_MIN, 0, 0, NULL },
|
M_OPT_MIN, 0, 0, NULL },
|
||||||
{ "avsync", mp_property_avsync, CONF_TYPE_DOUBLE },
|
{ "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 },
|
M_OPT_RANGE, 0, 100, NULL },
|
||||||
{ "time-pos", mp_property_time_pos, CONF_TYPE_TIME,
|
{ "time-pos", mp_property_time_pos, CONF_TYPE_TIME,
|
||||||
M_OPT_MIN, 0, 0, NULL },
|
M_OPT_MIN, 0, 0, NULL },
|
||||||
|
|
Loading…
Reference in New Issue