pub struct Mpv {
pub ctx: NonNull<mpv_handle>,
/* private fields */
}
Expand description
The central mpv context.
Fields§
§ctx: NonNull<mpv_handle>
The handle to the mpv core
Implementations§
Source§impl Mpv
impl Mpv
Sourcepub fn create_protocol_context<T, U>(&self) -> ProtocolContext<'_, T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
pub fn create_protocol_context<T, U>(&self) -> ProtocolContext<'_, T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
Create a context with which custom protocols can be registered.
§Panics
Panics if a context already exists
Source§impl Mpv
impl Mpv
Sourcepub fn new() -> Result<Mpv>
pub fn new() -> Result<Mpv>
Create a new Mpv
.
The default settings can be probed by running: $ mpv --show-profile=libmpv
.
Sourcepub fn with_initializer<F: FnOnce(MpvInitializer) -> Result<()>>(
initializer: F,
) -> Result<Mpv>
pub fn with_initializer<F: FnOnce(MpvInitializer) -> Result<()>>( initializer: F, ) -> Result<Mpv>
Create a new Mpv
.
The same as Mpv::new
, but you can set properties before Mpv
is initialized.
Sourcepub fn load_config(&self, path: &str) -> Result<()>
pub fn load_config(&self, path: &str) -> Result<()>
Load a configuration file. The path has to be absolute, and a file.
pub fn event_context(&self) -> &EventContext
pub fn event_context_mut(&mut self) -> &mut EventContext
Sourcepub fn command(&self, name: &str, args: &[&str]) -> Result<()>
pub fn command(&self, name: &str, args: &[&str]) -> Result<()>
Send a command to the Mpv
instance. This uses mpv_command_string
internally,
so that the syntax is the same as described in the manual for the input.conf.
Note that you may have to escape strings with ""
when they contain spaces.
§Examples
mpv.command("loadfile", &["test-data/jellyfish.mp4", "append-play"]).unwrap();
Sourcepub fn set_property<T: SetData>(&self, name: &str, data: T) -> Result<()>
pub fn set_property<T: SetData>(&self, name: &str, data: T) -> Result<()>
Set the value of a property.
Sourcepub fn get_property<T: GetData>(&self, name: &str) -> Result<T>
pub fn get_property<T: GetData>(&self, name: &str) -> Result<T>
Get the value of a property.
Sourcepub fn get_internal_time(&self) -> i64
pub fn get_internal_time(&self) -> i64
Internal time in microseconds, this has an arbitrary offset, and will never go backwards.
This can be called at any time, even if it was stated that no API function should be called.