mirror of
https://github.com/mpv-player/mpv
synced 2025-02-08 16:07:16 +00:00
command: change what the metadata property returns
Change the type of the property from a string list (alternating key/value entries) to a map. Using the client API, this will return MPV_FORMAT_NODE_MAP, while Lua mp.get_property_native returns a dictionary-like table.
This commit is contained in:
parent
3fe6426ae0
commit
392997fa10
@ -662,9 +662,15 @@ an option at runtime.
|
|||||||
Current DVD angle.
|
Current DVD angle.
|
||||||
|
|
||||||
``metadata``
|
``metadata``
|
||||||
Metadata key/value pairs. The raw property value will return a list of
|
Metadata key/value pairs.
|
||||||
key and value strings separated by ``,``. (If a key or value contains ``,``,
|
|
||||||
you're screwed.)
|
If the property is accessed with Lua's ``mp.get_property_native``, this
|
||||||
|
returns a table with metadata keys mapping to metadata values. If it is
|
||||||
|
accessed with the client API, this returns a ``MPV_FORMAT_NODE_MAP``,
|
||||||
|
with tag keys mapping to tag values.
|
||||||
|
|
||||||
|
For OSD, it returns a formatted list. Trying to retrieve this property as
|
||||||
|
a raw string doesn't work.
|
||||||
|
|
||||||
This has a number of sub-properties:
|
This has a number of sub-properties:
|
||||||
|
|
||||||
|
@ -827,14 +827,26 @@ static int tag_property(m_option_t *prop, int action, void *arg,
|
|||||||
{
|
{
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case M_PROPERTY_GET: {
|
case M_PROPERTY_GET: {
|
||||||
char **slist = NULL;
|
mpv_node_list *list = talloc_zero(NULL, mpv_node_list);
|
||||||
int num = 0;
|
mpv_node node = {
|
||||||
|
.format = MPV_FORMAT_NODE_MAP,
|
||||||
|
.u.list = list,
|
||||||
|
};
|
||||||
|
list->num = tags->num_keys;
|
||||||
|
list->values = talloc_array(list, mpv_node, list->num);
|
||||||
|
list->keys = talloc_array(list, char*, list->num);
|
||||||
for (int n = 0; n < tags->num_keys; n++) {
|
for (int n = 0; n < tags->num_keys; n++) {
|
||||||
MP_TARRAY_APPEND(NULL, slist, num, talloc_strdup(NULL, tags->keys[n]));
|
list->keys[n] = talloc_strdup(list, tags->keys[n]);
|
||||||
MP_TARRAY_APPEND(NULL, slist, num, talloc_strdup(NULL, tags->values[n]));
|
list->values[n] = (struct mpv_node){
|
||||||
|
.format = MPV_FORMAT_STRING,
|
||||||
|
.u.string = talloc_strdup(list, tags->values[n]),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
MP_TARRAY_APPEND(NULL, slist, num, NULL);
|
*(mpv_node*)arg = node;
|
||||||
*(char ***)arg = slist;
|
return M_PROPERTY_OK;
|
||||||
|
}
|
||||||
|
case M_PROPERTY_GET_TYPE: {
|
||||||
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
}
|
}
|
||||||
case M_PROPERTY_PRINT: {
|
case M_PROPERTY_PRINT: {
|
||||||
@ -2133,8 +2145,8 @@ static const m_option_t mp_properties[] = {
|
|||||||
0, 0, 0, NULL },
|
0, 0, 0, NULL },
|
||||||
{ "editions", mp_property_editions, CONF_TYPE_INT },
|
{ "editions", mp_property_editions, CONF_TYPE_INT },
|
||||||
{ "angle", mp_property_angle, &m_option_type_dummy },
|
{ "angle", mp_property_angle, &m_option_type_dummy },
|
||||||
{ "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST },
|
M_PROPERTY("metadata", mp_property_metadata),
|
||||||
{ "chapter-metadata", mp_property_chapter_metadata, CONF_TYPE_STRING_LIST },
|
M_PROPERTY("chapter-metadata", mp_property_chapter_metadata),
|
||||||
M_OPTION_PROPERTY_CUSTOM("pause", mp_property_pause),
|
M_OPTION_PROPERTY_CUSTOM("pause", mp_property_pause),
|
||||||
{ "cache", mp_property_cache, CONF_TYPE_INT },
|
{ "cache", mp_property_cache, CONF_TYPE_INT },
|
||||||
M_OPTION_PROPERTY("pts-association-mode"),
|
M_OPTION_PROPERTY("pts-association-mode"),
|
||||||
|
Loading…
Reference in New Issue
Block a user