mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 20:03:10 +02:00
command: add pseudo-property that allows you to read global options
The "options" pseudo-property allows reading global like this: show_text ${options/name} Where "name" maps to the option "--name". This allows retrieving option values that are not properties. Write-access is not possible: this is reserved for normal properties. Note: it is possible that we'll change this again, and don't require the "options/" prefix to access options.
This commit is contained in:
parent
ad1641c0da
commit
d1d6db25c0
@ -469,6 +469,7 @@ Name W Comment
|
|||||||
``track-list`` list of audio/video/sub tracks, cur. entr. marked
|
``track-list`` list of audio/video/sub tracks, cur. entr. marked
|
||||||
``chapter-list`` list of chapters, current entry marked
|
``chapter-list`` list of chapters, current entry marked
|
||||||
``quvi-format`` x see ``--quvi-format``
|
``quvi-format`` x see ``--quvi-format``
|
||||||
|
``options/name`` read-only access to value of option ``--name``
|
||||||
=============================== = ==================================================
|
=============================== = ==================================================
|
||||||
|
|
||||||
Property Expansion
|
Property Expansion
|
||||||
|
@ -1567,6 +1567,31 @@ static int mp_property_alias(m_option_t *prop, int action, void *arg,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mp_property_options(m_option_t *prop, int action, void *arg,
|
||||||
|
MPContext *mpctx)
|
||||||
|
{
|
||||||
|
if (action != M_PROPERTY_KEY_ACTION)
|
||||||
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
struct m_property_action_arg *ka = arg;
|
||||||
|
|
||||||
|
struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
|
||||||
|
bstr0(ka->key));
|
||||||
|
if (!opt)
|
||||||
|
return M_PROPERTY_UNKNOWN;
|
||||||
|
|
||||||
|
switch (ka->action) {
|
||||||
|
case M_PROPERTY_GET:
|
||||||
|
m_option_copy(opt->opt, ka->arg, opt->data);
|
||||||
|
return M_PROPERTY_OK;
|
||||||
|
case M_PROPERTY_GET_TYPE:
|
||||||
|
*(struct m_option *)ka->arg = *opt->opt;
|
||||||
|
return M_PROPERTY_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
// Use option-to-property-bridge. (The property and option have the same names.)
|
// Use option-to-property-bridge. (The property and option have the same names.)
|
||||||
#define M_OPTION_PROPERTY(name) \
|
#define M_OPTION_PROPERTY(name) \
|
||||||
{(name), mp_property_generic_option, &m_option_type_dummy, 0, 0, 0, (name)}
|
{(name), mp_property_generic_option, &m_option_type_dummy, 0, 0, 0, (name)}
|
||||||
@ -1737,6 +1762,8 @@ static const m_option_t mp_properties[] = {
|
|||||||
M_PROPERTY_ALIAS("audio", "aid"),
|
M_PROPERTY_ALIAS("audio", "aid"),
|
||||||
M_PROPERTY_ALIAS("sub", "sid"),
|
M_PROPERTY_ALIAS("sub", "sid"),
|
||||||
|
|
||||||
|
{ "options", mp_property_options, &m_option_type_dummy },
|
||||||
|
|
||||||
{0},
|
{0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user