mpv-client-dyn 0.5.0

Bindings for libmpv client API that allow you to create plugins for MPV in Rust
Documentation
  • Coverage
  • 62.9%
    39 out of 62 items documented0 out of 34 items with examples
  • Size
  • Source code size: 70.89 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.19 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • snylonue

MPV plugins in Rust

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

This is a fork of TheCactusVert/mpv-client that supports developing mpv c plugins on windows.

Currently, this crate is compatible with the original one.

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-dyn = "0.5.0"

And then the code src/lib.rs:

use mpv_client_dyn::{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.