mpv_format enum

Data format for options and properties. The API functions to get/set properties and options support multiple formats, and this enum describes them.

Inheritance
Available extensions

Values

MPV_FORMAT_NONE → const mpv_format

Invalid. Sometimes used for empty values. This is always defined to 0, so a normal 0-init of mpv_format (or e.g. mpv_node) is guaranteed to set this it to MPV_FORMAT_NONE (which makes some things saner as consequence).

const mpv_format(0)
MPV_FORMAT_STRING → const mpv_format

The basic type is char*. It returns the raw property string, like using ${=property} in input.conf (see input.rst).

NULL isn't an allowed value.

Warning: although the encoding is usually UTF-8, this is not always the case. File tags often store strings in some legacy codepage, and even filenames don't necessarily have to be in UTF-8 (at least on Linux). If you pass the strings to code that requires valid UTF-8, you have to sanitize it in some way. On Windows, filenames are always UTF-8, and libmpv converts between UTF-8 and UTF-16 when using win32 API functions. See the "Encoding of filenames" section for details.

Example for reading:

char *result = NULL; if (mpv_get_property(ctx, "property", MPV_FORMAT_STRING, &result) < 0) goto error; printf("%s\n", result); mpv_free(result);

Or just use mpv_get_property_string().

Example for writing:

char *value = "the new value"; // yep, you pass the address to the variable // (needed for symmetry with other types and mpv_get_property) mpv_set_property(ctx, "property", MPV_FORMAT_STRING, &value);

Or just use mpv_set_property_string().

const mpv_format(1)
MPV_FORMAT_OSD_STRING → const mpv_format

The basic type is char*. It returns the OSD property string, like using ${property} in input.conf (see input.rst). In many cases, this is the same as the raw string, but in other cases it's formatted for display on OSD. It's intended to be human readable. Do not attempt to parse these strings.

Only valid when doing read access. The rest works like MPV_FORMAT_STRING.

const mpv_format(2)
MPV_FORMAT_FLAG → const mpv_format

The basic type is int. The only allowed values are 0 ("no") and 1 ("yes").

Example for reading:

int result; if (mpv_get_property(ctx, "property", MPV_FORMAT_FLAG, &result) < 0) goto error; printf("%s\n", result ? "true" : "false");

Example for writing:

int flag = 1; mpv_set_property(ctx, "property", MPV_FORMAT_FLAG, &flag);

const mpv_format(3)
MPV_FORMAT_INT64 → const mpv_format

The basic type is int64_t.

const mpv_format(4)
MPV_FORMAT_DOUBLE → const mpv_format

The basic type is double.

const mpv_format(5)
MPV_FORMAT_NODE → const mpv_format

The type is mpv_node.

For reading, you usually would pass a pointer to a stack-allocated mpv_node value to mpv, and when you're done you call mpv_free_node_contents(&node). You're expected not to write to the data - if you have to, copy it first (which you have to do manually).

For writing, you construct your own mpv_node, and pass a pointer to the API. The API will never write to your data (and copy it if needed), so you're free to use any form of allocation or memory management you like.

Warning: when reading, always check the mpv_node.format member. For example, properties might change their type in future versions of mpv, or sometimes even during runtime.

Example for reading:

mpv_node result; if (mpv_get_property(ctx, "property", MPV_FORMAT_NODE, &result) < 0) goto error; printf("format=%d\n", (int)result.format); mpv_free_node_contents(&result).

Example for writing:

mpv_node value; value.format = MPV_FORMAT_STRING; value.u.string = "hello"; mpv_set_property(ctx, "property", MPV_FORMAT_NODE, &value);

const mpv_format(6)
MPV_FORMAT_NODE_ARRAY → const mpv_format

Used with mpv_node only. Can usually not be used directly.

const mpv_format(7)
MPV_FORMAT_NODE_MAP → const mpv_format

See MPV_FORMAT_NODE_ARRAY.

const mpv_format(8)
MPV_FORMAT_BYTE_ARRAY → const mpv_format

A raw, untyped byte array. Only used only with mpv_node, and only in some very specific situations. (Some commands use it.)

const mpv_format(9)

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value int
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromValue(int value) mpv_format

Constants

values → const List<mpv_format>
A constant List of the values in this enum, in order of their declaration.