Crate mrc

Source
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, and playlist-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§

Constants§

Functions§

  • Sends the get_property command to retrieve a property value from MPV.
  • Sends the loadfile command to load a file into MPV.
  • Sends the playlist-clear command to clear the playlist.
  • Sends the playlist-move command to move a playlist item from one index to another.
  • Sends the playlist-next command to move to the next playlist item.
  • Sends the playlist-prev command to move to the previous playlist item.
  • Sends the playlist-remove command to remove an item from the playlist.
  • Sends the quit command to terminate MPV.
  • Sends the seek command to seek the media playback by a given number of seconds.
  • Sends a generic IPC command to the specified socket and returns the parsed response data.
  • Sends the set_property command to MPV to change a property value.