Support using from `mpv_open_cplugin`.
Closed this issue · 1 comments
eNV25 commented
It's possible to use Rust to create an MPV plugin.
[package]
name = "test-mpv-cplugin"
version = "0.1.0"
edition = "2021"
[lib]
name = "test_mpv_cplugin"
crate-type = ["cdylib"]
[dependencies]
libmpv-sys = "3.1.0"
use libmpv_sys::*;
use std::ffi::*;
#[no_mangle]
extern "C" fn mpv_open_cplugin(handle: *mut mpv_handle) -> usize {
let client_name = unsafe { CStr::from_ptr(mpv_client_name(handle)) }
.to_str()
.unwrap_or_default();
println!("Hello from {}", client_name);
0
}
$ cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
$ mpv --no-config --script=target/debug/libtest_mpv_cplugin.so test.png
Hello from libtest_mpv_cplugin
(+) Video --vid=1 (png 1118x924 1.000fps)
VO: [gpu] 1118x924 rgba
V: 00:00:00 / 00:00:00 (0%)
Exiting... (End of file)
It would be useful to use the main crate instead of the -sys
crate. Should be as simple as adding a constructor from_ptr
for struct Mpv
.
ryze312 commented
Bump @ParadoxSpiral
The only alternative at the moment is this repo