Crate mpvipc_async

Crate mpvipc_async 

Source
Expand description

Coverage Docs

ยงmpvipc-async

[!NOTE] This is a fork of gitlab.com/mpv-ipc/mpvipc. The fork adds support for use in asynchronous contexts.

A small library which provides bindings to control existing mpv instances through sockets.

ยงDependencies

  • mpv (runtime dependency)
  • cargo-nextest (optional test depencency)
  • grcov (optional test depencency)

ยงExample

Make sure mpv is started with the following option:

$ mpv --input-ipc-server=/tmp/mpv.sock --idle

Here is a small code example which connects to the socket /tmp/mpv.sock and toggles playback.

use mpvipc_async::*;

#[tokio::main]
async fn main() -> Result<(), MpvError> {
    let mpv = Mpv::connect("/tmp/mpv.sock").await?;
    let paused: bool = mpv.get_property("pause").await?;
    mpv.set_property("pause", !paused).await.expect("Error pausing");
}

You can find more examples in the examples directory

Modulesยง

core_api ๐Ÿ”’
The core API for interacting with Mpv.
error ๐Ÿ”’
Library specific error messages.
event_parser ๐Ÿ”’
JSON parsing logic for events from MpvIpc.
highlevel_api_extension ๐Ÿ”’
High-level API extension for Mpv.
ipc ๐Ÿ”’
IPC handling thread/task. Handles communication between Mpv instances and mpvโ€™s unix socket
message_parser ๐Ÿ”’
JSON parsing logic for command responses from MpvIpc.
property_parser ๐Ÿ”’
JSON parsing logic for properties returned by [Event::PropertyChange], and used internally in MpvExt to parse the response from Mpv::get_property().

Structsยง

Mpv
The main struct for interacting with mpv.
Playlist
A mpv playlist.
PlaylistEntry
A single entry in the mpv playlist.

Enumsยง

Event
All possible events that can be sent by mpv.
EventEndFileReason
Reason behind the MPV_EVENT_END_FILE event.
EventLogMessageLevel
The log level of a log message event.
LoopProperty
Loop mode used by mpv for files and playlists.
MpvCommand
All possible commands that can be sent to mpv.
MpvDataType
Generic data type representing all possible data types that mpv can return.
MpvError
Any error that can occur when interacting with mpv.
NumberChangeOptions
Generic high-level command for changing a number property.
PlaylistAddOptions
Options for MpvCommand::LoadFile and MpvCommand::LoadList.
PlaylistAddTypeOptions
Options for MpvExt::playlist_add.
Property
An incomplete list of properties that mpv can return.
SeekOptions
Options for MpvCommand::Seek.
Switch
Generic high-level switch for toggling boolean properties.

Traitsยง

GetPropertyTypeHandler
A trait for specifying how to extract and parse a value returned through Mpv::get_property.
MpvExt
A set of typesafe high-level functions to interact with Mpv.
SetPropertyTypeHandler
A trait for specifying how to serialize and set a value through Mpv::set_property.

Functionsยง

parse_property
Parse a highlevel Property object from mpv data.