#mpv #libmpv #api-client #bindings #create #plugin

sys mpv-client-sys

Raw bindings for libmpv client API

1 stable release

1.0.1 Aug 25, 2024

#4 in #libmpv

Download history 214/week @ 2024-08-23 26/week @ 2024-08-30 10/week @ 2024-09-06 86/week @ 2024-09-13 45/week @ 2024-09-20 29/week @ 2024-09-27 16/week @ 2024-10-04 16/week @ 2024-10-11 9/week @ 2024-10-18

75 downloads per month
Used in mpv-client

GPL-3.0 license

3KB

MPV plugins in Rust

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

Example

Here is an example for your Cargo.toml:

[package]
name = "mpv-plugin"
version = "0.1.0"
edition = "2021"

[lib]
name = "mpv_plugin"
crate-type = ["cdylib"]

[dependencies]
mpv-client = "0.6.2"

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.

No runtime deps

~0–1.9MB
~37K SLoC