mpv-client-cross 1.2.2

Bindings for libmpv client API that allow you to create plugins for MPV in Rust
Documentation

MPV plugins in Rust

Bindings for libmpv client API that allow you to create plugins for MPV in Rust.

⚠️ About this Fork: This is a maintained fork of the original TheCactusVert/mpv-client.

Key improvements in this fork:

  • Windows Support: Added out-of-the-box support for Windows compilation (via MPV_CPLUGIN_DYNAMIC_SYM linkage-to-libmpv).
  • No LLVM/Clang required: Uses pregenerated bindings by default, meaning you don't need bindgen or a local LLVM installation during cargo build.

Example

Here is an example for your Cargo.toml:

[package]

name = "mpv-plugin"

version = "0.1.0"

edition = "2024"



[lib]

name = "mpv_plugin"

crate-type = ["cdylib"]



[dependencies]

mpv-client = { version = "1.2", package = "mpv-client-cross" }

And then the code src/lib.rs:

use mpv_client::{mpv_handle, Event, Handle};

#[no_mangle]
extern "C" fn mpv_open_cplugin(handle: *mut mpv_handle) -> std::os::raw::c_int {
  let client = Handle::from_ptr(handle);
  
  println!("Hello world from Rust plugin {}!", client.name());
  
  loop {
    match client.wait_event(-1.) {
      Event::Shutdown => { return 0; },
      event => { println!("Got event: {}", event); },
    }
  }
}

You can find more examples in C and Rust.