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

mpv-client

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

8 releases

0.6.2 Mar 23, 2024
0.6.0 Jan 11, 2024
0.5.0 Feb 11, 2023
0.3.2 Dec 30, 2022
0.3.1 Nov 3, 2022

#4 in #mpv

Download history 30/week @ 2024-01-10 17/week @ 2024-01-17 2/week @ 2024-02-07 67/week @ 2024-02-14 15/week @ 2024-02-21 163/week @ 2024-02-28 31/week @ 2024-03-06 71/week @ 2024-03-13 159/week @ 2024-03-20 19/week @ 2024-03-27 57/week @ 2024-04-03 6/week @ 2024-04-10

241 downloads per month

GPL-3.0 license

32KB
610 lines

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