Expand description
MRC A library for interacting with the MPV media player using its JSON IPC (Inter-Process Communication) protocol.
This crate provides a set of utilities to communicate with MPV’s IPC socket, enabling you to send commands and retrieve responses in a structured format.
§Features
- Send commands to MPV’s IPC socket
- Retrieve responses in JSON format
- Supports common MPV commands like
set_property,seek, andplaylist-next - Flexible socket path configuration
§Example Usage
use serde_json::json;
use tokio;
use mrc::{send_ipc_command, playlist_next, set_property};
#[tokio::main]
async fn main() {
let result = playlist_next(None).await;
match result {
Ok(response) => println!("Playlist moved to next: {:?}", response),
Err(err) => eprintln!("Error: {:?}", err),
}
let property_result = set_property("volume", &json!(50), None).await;
match property_result {
Ok(response) => println!("Volume set: {:?}", response),
Err(err) => eprintln!("Error: {:?}", err),
}
}§Constants
§SOCKET_PATH
Default path for the MPV IPC socket: /tmp/mpvsocket
§Functions
Enums§
- MpvCommand
- Represents common MPV commands.
Constants§
Functions§
- get_
property - Sends the
get_propertycommand to retrieve a property value from MPV. - loadfile
- Sends the
loadfilecommand to load a file into MPV. - playlist_
clear - Sends the
playlist-clearcommand to clear the playlist. - playlist_
move - Sends the
playlist-movecommand to move a playlist item from one index to another. - playlist_
next - Sends the
playlist-nextcommand to move to the next playlist item. - playlist_
prev - Sends the
playlist-prevcommand to move to the previous playlist item. - playlist_
remove - Sends the
playlist-removecommand to remove an item from the playlist. - quit
- Sends the
quitcommand to terminate MPV. - seek
- Sends the
seekcommand to seek the media playback by a given number of seconds. - send_
ipc_ command - Sends a generic IPC command to the specified socket and returns the parsed response data.
- set_
property - Sends the
set_propertycommand to MPV to change a property value.