mirror of
https://github.com/mpv-player/mpv
synced 2025-03-02 20:28:02 +00:00
command: scale osd’s time remaining by the current speed
Signed-off-by: wm4 <wm4@nowhere>
This commit is contained in:
parent
e51808ea22
commit
908dfa7949
@ -534,6 +534,7 @@ Name W Comment
|
|||||||
``ratio-pos`` x position in current file (0.0-1.0)
|
``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
|
||||||
|
``playtime-remaining`` ``time-remaining`` scaled by the the current ``speed``
|
||||||
``chapter`` x current chapter number
|
``chapter`` x current chapter number
|
||||||
``edition`` x current MKV edition number
|
``edition`` x current MKV edition number
|
||||||
``titles`` number of DVD titles
|
``titles`` number of DVD titles
|
||||||
|
@ -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));
|
return property_time(prop, action, arg, get_current_time(mpctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double time_remaining(MPContext *mpctx, double *len)
|
||||||
|
{
|
||||||
|
*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,
|
static int mp_property_remaining(m_option_t *prop, int action,
|
||||||
void *arg, MPContext *mpctx)
|
void *arg, MPContext *mpctx)
|
||||||
{
|
{
|
||||||
double len = get_time_length(mpctx);
|
double len;
|
||||||
double pos = get_current_time(mpctx);
|
double remaining = time_remaining(mpctx, &len);
|
||||||
double start = get_start_time(mpctx);
|
|
||||||
|
|
||||||
if (!(int)len)
|
if (!(int)len)
|
||||||
return M_PROPERTY_UNAVAILABLE;
|
return M_PROPERTY_UNAVAILABLE;
|
||||||
|
|
||||||
return property_time(prop, action, arg, len - (pos - start));
|
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;
|
||||||
|
|
||||||
|
double speed = mpctx->opts->playback_speed;
|
||||||
|
return property_time(prop, action, arg, remaining / speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Current chapter (RW)
|
/// Current chapter (RW)
|
||||||
@ -1881,6 +1902,7 @@ static const m_option_t mp_properties[] = {
|
|||||||
{ "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 },
|
||||||
{ "time-remaining", mp_property_remaining, CONF_TYPE_TIME },
|
{ "time-remaining", mp_property_remaining, CONF_TYPE_TIME },
|
||||||
|
{ "playtime-remaining", mp_property_playtime_remaining, CONF_TYPE_TIME },
|
||||||
{ "chapter", mp_property_chapter, CONF_TYPE_INT,
|
{ "chapter", mp_property_chapter, CONF_TYPE_INT,
|
||||||
M_OPT_MIN, -1, 0, NULL },
|
M_OPT_MIN, -1, 0, NULL },
|
||||||
M_OPTION_PROPERTY_CUSTOM("edition", mp_property_edition),
|
M_OPTION_PROPERTY_CUSTOM("edition", mp_property_edition),
|
||||||
|
@ -1020,9 +1020,9 @@ function osc_init()
|
|||||||
local contentF = function (ass)
|
local contentF = function (ass)
|
||||||
if state.rightTC_trem == true then
|
if state.rightTC_trem == true then
|
||||||
if state.tc_ms 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
|
else
|
||||||
ass:append("-" .. mp.property_get_string("time-remaining"))
|
ass:append("-" .. mp.property_get_string("playtime-remaining"))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if state.tc_ms then
|
if state.tc_ms then
|
||||||
|
Loading…
Reference in New Issue
Block a user