mpv-client

Crates.iompv-client
lib.rsmpv-client
version0.6.2
sourcesrc
created_at2022-10-31 20:13:22.868693
updated_at2024-03-23 09:15:50.463203
descriptionBindings for libmpv client API that allow you to create plugins for MPV in Rust
homepage
repositoryhttps://github.com/TheCactusVert/mpv-client
max_upload_size
id702380
size66,524
Kevin Gavrois (TheCactusVert)

documentation

README

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.

Commit count: 69

cargo fmt