#mpv #sockets #instance #playback-control #bindings #idle

mpvipc

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

16 stable releases

1.3.1 Feb 15, 2026
1.3.0 Aug 3, 2023
1.2.2 Jul 21, 2022
1.1.9 Oct 24, 2020
1.1.1 May 31, 2017

#92 in Multimedia

45 downloads per month
Used in 3 crates

GPL-3.0 license

59KB
1.5K SLoC

mpvipc

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

To make use of this library, please make sure mpv is started with the following option: $ mpv --input-ipc-server=/tmp/mpv --idle # Linux $ mpv --input-ipc-server=\\.\mpv --idle # Windows

Dependencies

  • mpv
  • cargo (makedep)

Install

You can use this package with cargo.

Example

Make sure mpv is started with the following option: $ mpv --input-ipc-server=/tmp/mpv --idle # Linux $ mpv --input-ipc-server=\\.\mpv --idle # Windows

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

extern crate mpvipc;

use mpvipc::*;
use std::sync::mpsc::channel;

#[cfg(unix)]
const SOCKET: &str = "/tmp/mpv";

#[cfg(windows)]
const SOCKET: &str = r"\\.\mpv";

fn main() {
    let mpv = Mpv::connect(SOCKET).unwrap();
    let paused: bool = mpv.get_property("pause").unwrap();
    mpv.set_property("pause", !paused).expect("Error pausing");
}

For a more extensive example and proof of concept, see project mpvc.

Bugs / Ideas

Check out the Issue Tracker

Dependencies

~0.3–0.9MB
~17K SLoC