mpv.client

Undocumented in source.

Members

Enums

mpv_end_file_reason
enum mpv_end_file_reason

Since API version 1.9.

mpv_error
enum mpv_error

List of error codes than can be returned by API functions. 0 and positive return values always mean success, negative values are always errors.

mpv_event_id
enum mpv_event_id
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
mpv_format
enum mpv_format

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

mpv_log_level
enum mpv_log_level

Numeric log levels. The lower the number, the more important the message is. MPV_LOG_LEVEL_NONE is never used when receiving messages. The string in the comment after the value is the name of the log level as used for the mpv_request_log_messages() function. Unused numeric values are unused, but reserved for future use.

mpv_sub_api
enum mpv_sub_api

@deprecated use render.h

Functions

MPV_MAKE_VERSION
auto MPV_MAKE_VERSION(T0 major, T1 minor)

The version is incremented on each API change. The 16 lower bits form the minor version number, and the 16 higher bits the major version number. If the API becomes incompatible to previous versions, the major version number is incremented. This affects only C part, and not properties and options.

mpv_abort_async_command
void mpv_abort_async_command(mpv_handle* ctx, ulong reply_userdata)

Signal to all async requests with the matching ID to abort. This affects the following API calls:

mpv_client_api_version
c_ulong mpv_client_api_version()

Return the MPV_CLIENT_API_VERSION the mpv source has been compiled with.

mpv_client_name
const(char)* mpv_client_name(mpv_handle* ctx)

Return the name of this client handle. Every client has its own unique name, which is mostly used for user interface purposes.

mpv_command
int mpv_command(mpv_handle* ctx, const(char*)* args)

Send a command to the player. Commands are the same as those used in input.conf, except that this function takes parameters in a pre-split form.

mpv_command_async
int mpv_command_async(mpv_handle* ctx, ulong reply_userdata, const(char*)* args)

Same as mpv_command, but run the command asynchronously.

mpv_command_node
int mpv_command_node(mpv_handle* ctx, mpv_node* args, mpv_node* result)

Same as mpv_command(), but allows passing structured data in any format. In particular, calling mpv_command() is exactly like calling mpv_command_node() with the format set to MPV_FORMAT_NODE_ARRAY, and every arg passed in order as MPV_FORMAT_STRING.

mpv_command_node_async
int mpv_command_node_async(mpv_handle* ctx, ulong reply_userdata, mpv_node* args)

Same as mpv_command_node(), but run it asynchronously. Basically, this function is to mpv_command_node() what mpv_command_async() is to mpv_command().

mpv_command_ret
int mpv_command_ret(mpv_handle* ctx, const(char*)* args, mpv_node* result)

This is essentially identical to mpv_command() but it also returns a result.

mpv_command_string
int mpv_command_string(mpv_handle* ctx, const(char)* args)

Same as mpv_command, but use input.conf parsing for splitting arguments. This is slightly simpler, but also more error prone, since arguments may need quoting/escaping.

mpv_create
mpv_handle* mpv_create()

Create a new mpv instance and an associated client API handle to control the mpv instance. This instance is in a pre-initialized state, and needs to be initialized to be actually used with most other API functions.

mpv_create_client
mpv_handle* mpv_create_client(mpv_handle* ctx, const(char)* name)

Create a new client handle connected to the same player core as ctx. This context has its own event queue, its own mpv_request_event() state, its own mpv_request_log_messages() state, its own set of observed properties, and its own state for asynchronous operations. Otherwise, everything is shared.

mpv_create_weak_client
mpv_handle* mpv_create_weak_client(mpv_handle* ctx, const(char)* name)

This is the same as mpv_create_client(), but the created mpv_handle is treated as a weak reference. If all mpv_handles referencing a core are weak references, the core is automatically destroyed. (This still goes through normal uninit of course. Effectively, if the last non-weak mpv_handle is destroyed, then the weak mpv_handles receive MPV_EVENT_SHUTDOWN and are asked to terminate as well.)

mpv_destroy
void mpv_destroy(mpv_handle* ctx)

Disconnect and destroy the mpv_handle. ctx will be deallocated with this API call.

mpv_detach_destroy
void mpv_detach_destroy(mpv_handle* ctx)

@deprecated use mpv_destroy(), which has exactly the same semantics (the deprecation is a mere rename)

mpv_error_string
const(char)* mpv_error_string(int error)

Return a string describing the error. For unknown errors, the string "unknown error" is returned.

mpv_event_name
const(char)* mpv_event_name(mpv_event_id event)

Return a string describing the event. For unknown events, NULL is returned.

mpv_free
void mpv_free(void* data)

General function to deallocate memory returned by some of the API functions. Call this only if it's explicitly documented as allowed. Calling this on mpv memory not owned by the caller will lead to undefined behavior.

mpv_free_node_contents
void mpv_free_node_contents(mpv_node* node)

Frees any data referenced by the node. It doesn't free the node itself. Call this only if the mpv client API set the node. If you constructed the node yourself (manually), you have to free it yourself.

mpv_get_property
int mpv_get_property(mpv_handle* ctx, const(char)* name, mpv_format format, void* data)

Read the value of the given property.

mpv_get_property_async
int mpv_get_property_async(mpv_handle* ctx, ulong reply_userdata, const(char)* name, mpv_format format)

Get a property asynchronously. You will receive the result of the operation as well as the property data with the MPV_EVENT_GET_PROPERTY_REPLY event. You should check the mpv_event.error field on the reply event.

mpv_get_property_osd_string
char* mpv_get_property_osd_string(mpv_handle* ctx, const(char)* name)

Return the property as "OSD" formatted string. This is the same as mpv_get_property_string, but using MPV_FORMAT_OSD_STRING.

mpv_get_property_string
char* mpv_get_property_string(mpv_handle* ctx, const(char)* name)

Return the value of the property with the given name as string. This is equivalent to mpv_get_property() with MPV_FORMAT_STRING.

mpv_get_sub_api
void* mpv_get_sub_api(mpv_handle* ctx, mpv_sub_api sub_api)

This is used for additional APIs that are not strictly part of the core API. See the individual mpv_sub_api member values.

mpv_get_time_us
long mpv_get_time_us(mpv_handle* ctx)

Return the internal time in microseconds. This has an arbitrary start offset, but will never wrap or go backwards.

mpv_get_wakeup_pipe
int mpv_get_wakeup_pipe(mpv_handle* ctx)

Return a UNIX file descriptor referring to the read end of a pipe. This pipe can be used to wake up a poll() based processing loop. The purpose of this function is very similar to mpv_set_wakeup_callback(), and provides a primitive mechanism to handle coordinating a foreign event loop and the libmpv event loop. The pipe is non-blocking. It's closed when the mpv_handle is destroyed. This function always returns the same value (on success).

mpv_hook_add
int mpv_hook_add(mpv_handle* ctx, ulong reply_userdata, const(char)* name, int priority)

A hook is like a synchronous event that blocks the player. You register a hook handler with this function. You will get an event, which you need to handle, and once things are ready, you can let the player continue with mpv_hook_continue().

mpv_hook_continue
int mpv_hook_continue(mpv_handle* ctx, ulong id)

Respond to a MPV_EVENT_HOOK event. You must call this after you have handled the event. There is no way to "cancel" or "stop" the hook.

mpv_initialize
int mpv_initialize(mpv_handle* ctx)

Initialize an uninitialized mpv instance. If the mpv instance is already running, an error is returned.

mpv_load_config_file
int mpv_load_config_file(mpv_handle* ctx, const(char)* filename)

Load a config file. This loads and parses the file, and sets every entry in the config file's default section as if mpv_set_option_string() is called.

mpv_observe_property
int mpv_observe_property(mpv_handle* mpv, ulong reply_userdata, const(char)* name, mpv_format format)

Get a notification whenever the given property changes. You will receive updates as MPV_EVENT_PROPERTY_CHANGE. Note that this is not very precise: for some properties, it may not send updates even if the property changed. This depends on the property, and it's a valid feature request to ask for better update handling of a specific property. (For some properties, like `clock`, which shows the wall clock, this mechanism doesn't make too much sense anyway.)

mpv_request_event
int mpv_request_event(mpv_handle* ctx, mpv_event_id event, int enable)

Enable or disable the given event.

mpv_request_log_messages
int mpv_request_log_messages(mpv_handle* ctx, const(char)* min_level)

Enable or disable receiving of log messages. These are the messages the command line player prints to the terminal. This call sets the minimum required log level for a message to be received with MPV_EVENT_LOG_MESSAGE.

mpv_resume
void mpv_resume(mpv_handle* ctx)

See mpv_suspend().

mpv_set_option
int mpv_set_option(mpv_handle* ctx, const(char)* name, mpv_format format, void* data)

Set an option. Note that you can't normally set options during runtime. It works in uninitialized state (see mpv_create()), and in some cases in at runtime.

mpv_set_option_string
int mpv_set_option_string(mpv_handle* ctx, const(char)* name, const(char)* data)

Convenience function to set an option to a string value. This is like calling mpv_set_option() with MPV_FORMAT_STRING.

mpv_set_property
int mpv_set_property(mpv_handle* ctx, const(char)* name, mpv_format format, void* data)

Set a property to a given value. Properties are essentially variables which can be queried or set at runtime. For example, writing to the pause property will actually pause or unpause playback.

mpv_set_property_async
int mpv_set_property_async(mpv_handle* ctx, ulong reply_userdata, const(char)* name, mpv_format format, void* data)

Set a property asynchronously. You will receive the result of the operation as MPV_EVENT_SET_PROPERTY_REPLY event. The mpv_event.error field will contain the result status of the operation. Otherwise, this function is similar to mpv_set_property().

mpv_set_property_string
int mpv_set_property_string(mpv_handle* ctx, const(char)* name, const(char)* data)

Convenience function to set a property to a string value.

mpv_set_wakeup_callback
void mpv_set_wakeup_callback(mpv_handle* ctx, void function(void* d) cb, void* d)

Set a custom function that should be called when there are new events. Use this if blocking in mpv_wait_event() to wait for new events is not feasible.

mpv_suspend
void mpv_suspend(mpv_handle* ctx)

This does nothing since mpv 0.23.0 (API version 1.24). Below is the description of the old behavior.

mpv_terminate_destroy
void mpv_terminate_destroy(mpv_handle* ctx)

Similar to mpv_destroy(), but brings the player and all clients down as well, and waits until all of them are destroyed. This function blocks. The advantage over mpv_destroy() is that while mpv_destroy() merely detaches the client handle from the player, this function quits the player, waits until all other clients are destroyed (i.e. all mpv_handles are detached), and also waits for the final termination of the player.

mpv_unobserve_property
int mpv_unobserve_property(mpv_handle* mpv, ulong registered_reply_userdata)

Undo mpv_observe_property(). This will remove all observed properties for which the given number was passed as reply_userdata to mpv_observe_property.

mpv_wait_async_requests
void mpv_wait_async_requests(mpv_handle* ctx)

Block until all asynchronous requests are done. This affects functions like mpv_command_async(), which return immediately and return their result as events.

mpv_wait_event
mpv_event* mpv_wait_event(mpv_handle* ctx, double timeout)

Wait for the next event, or until the timeout expires, or if another thread makes a call to mpv_wakeup(). Passing 0 as timeout will never wait, and is suitable for polling.

mpv_wakeup
void mpv_wakeup(mpv_handle* ctx)

Interrupt the current mpv_wait_event() call. This will wake up the thread currently waiting in mpv_wait_event(). If no thread is waiting, the next mpv_wait_event() call will return immediately (this is to avoid lost wakeups).

Manifest constants

MPV_CLIENT_API_VERSION
enum MPV_CLIENT_API_VERSION;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
MPV_ENABLE_DEPRECATED
enum MPV_ENABLE_DEPRECATED;

The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before including any libmpv headers. Then deprecated symbols will be excluded from the headers. (Of course, deprecated properties and commands and other functionality will still work.)

Structs

mpv_byte_array
struct mpv_byte_array

(see mpv_node)

mpv_event
struct mpv_event
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
mpv_event_client_message
struct mpv_event_client_message
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
mpv_event_command
struct mpv_event_command
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
mpv_event_end_file
struct mpv_event_end_file
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
mpv_event_hook
struct mpv_event_hook
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
mpv_event_log_message
struct mpv_event_log_message
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
mpv_event_property
struct mpv_event_property
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
mpv_event_script_input_dispatch
struct mpv_event_script_input_dispatch

@deprecated see MPV_EVENT_SCRIPT_INPUT_DISPATCH for remarks

mpv_handle
struct mpv_handle

Client context used by the client API. Every client has its own private handle.

mpv_node
struct mpv_node

Generic data storage.

mpv_node_list
struct mpv_node_list

(see mpv_node)

Meta