Struct mpv_client::Handle

source ·
pub struct Handle(_);
Expand description

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

Implementations

Wrap a raw mpv_handle The pointer must not be null

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.

The internal event queue has a limited size (per client handle). If you don’t empty the event queue quickly enough with Handle::wait_event, it will overflow and silently discard further events. If this happens, making asynchronous requests will fail as well (with MPV_ERROR_EVENT_QUEUE_FULL).

Only one thread is allowed to call this on the same Handle at a time. The API won’t complain if more than one thread calls this, but it will cause race conditions in the client when accessing the shared mpv_event struct. Note that most other API functions are not restricted by this, and no API function internally calls mpv_wait_event(). Additionally, concurrent calls to different handles are always safe.

As long as the timeout is 0, this is safe to be called from mpv render API threads.

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

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.

Same as Handle::command, but run the command asynchronously.

Commands are executed asynchronously. You will receive a CommandReply event. This event will also have an error code set if running the command failed. For commands that return data, the data is put into mpv_event_command.result.

The only case when you do not receive an event is when the function call itself fails. This happens only if parsing the command itself (or otherwise validating it) fails, i.e. the return code of the API call is not 0 or positive.

Safe to be called from mpv render API threads.

Display a message on the screen. See Handle::command

Same as Handle::osd_command, but run the command asynchronously. See Handle::command_async

Read the value of the given property.

If the format doesn’t match with the internal format of the property, access usually will fail with MPV_ERROR_PROPERTY_FORMAT. In some cases, the data is automatically converted and access succeeds. For example, i64 is always converted to f64, and access using String usually invokes a string formatter.

Undo Handle::observe_property. This will remove all observed properties for which the given number was passed as reply_userdata to Handle::observe_property.

Safe to be called from mpv render API threads.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.