pub struct Mpv { /* private fields */ }
Implementations§
Source§impl Mpv
impl Mpv
pub fn connect(socket: &str) -> Result<Mpv, Error>
pub fn disconnect(&self)
pub fn get_stream_ref(&self) -> &UnixStream
pub fn get_metadata(&self) -> Result<HashMap<String, MpvDataType>, Error>
pub fn get_playlist(&self) -> Result<Playlist, Error>
Sourcepub fn get_property<T: GetPropertyTypeHandler>(
&self,
property: &str,
) -> Result<T, Error>
pub fn get_property<T: GetPropertyTypeHandler>( &self, property: &str, ) -> Result<T, Error>
§Description
Retrieves the property value from mpv.
§Supported types
- String
- bool
- HashMap<String, String> (e.g. for the ‘metadata’ property)
- Vec
(for the ‘playlist’ property) - usize
- f64
§Input arguments
- property defines the mpv property that should be retrieved
§Example
use mpvipc::{Mpv, Error};
fn main() -> Result<(), Error> {
let mpv = Mpv::connect("/tmp/mpvsocket")?;
let paused: bool = mpv.get_property("pause")?;
let title: String = mpv.get_property("media-title")?;
Ok(())
}
Sourcepub fn get_property_string(&self, property: &str) -> Result<String, Error>
pub fn get_property_string(&self, property: &str) -> Result<String, Error>
§Description
Retrieves the property value from mpv. The result is always of type String, regardless of the type of the value of the mpv property
§Input arguments
- property defines the mpv property that should be retrieved
§Example
use mpvipc::{Mpv, Error};
fn main() -> Result<(), Error> {
let mpv = Mpv::connect("/tmp/mpvsocket")?;
let title = mpv.get_property_string("media-title")?;
Ok(())
}
pub fn kill(&self) -> Result<(), Error>
Sourcepub fn event_listen(&mut self) -> Result<Event, Error>
pub fn event_listen(&mut self) -> Result<Event, Error>
pub fn event_listen_raw(&mut self) -> String
pub fn next(&self) -> Result<(), Error>
pub fn observe_property(&self, id: isize, property: &str) -> Result<(), Error>
pub fn unobserve_property(&self, id: isize) -> Result<(), Error>
pub fn pause(&self) -> Result<(), Error>
pub fn prev(&self) -> Result<(), Error>
pub fn restart(&self) -> Result<(), Error>
Sourcepub fn run_command(&self, command: MpvCommand) -> Result<(), Error>
pub fn run_command(&self, command: MpvCommand) -> Result<(), Error>
§Description
Runs mpv commands. The arguments are passed as a String-Vector reference:
§Input arguments
- command defines the mpv command that should be executed
- args a slice of &str’s which define the arguments
§Example
use mpvipc::{Mpv, Error};
fn main() -> Result<(), Error> {
let mpv = Mpv::connect("/tmp/mpvsocket")?;
//Run command 'playlist-shuffle' which takes no arguments
mpv.run_command(MpvCommand::PlaylistShuffle)?;
//Run command 'seek' which in this case takes two arguments
mpv.run_command(MpvCommand::Seek {
seconds: 0f64,
option: SeekOptions::Absolute,
})?;
Ok(())
}
Sourcepub fn run_command_raw(&self, command: &str, args: &[&str]) -> Result<(), Error>
pub fn run_command_raw(&self, command: &str, args: &[&str]) -> Result<(), Error>
Run a custom command. This should only be used if the desired command is not implemented with MpvCommand.
pub fn playlist_add( &self, file: &str, file_type: PlaylistAddTypeOptions, option: PlaylistAddOptions, ) -> Result<(), Error>
pub fn playlist_clear(&self) -> Result<(), Error>
pub fn playlist_move_id(&self, from: usize, to: usize) -> Result<(), Error>
pub fn playlist_play_id(&self, id: usize) -> Result<(), Error>
pub fn playlist_play_next(&self, id: usize) -> Result<(), Error>
pub fn playlist_remove_id(&self, id: usize) -> Result<(), Error>
pub fn playlist_shuffle(&self) -> Result<(), Error>
pub fn seek(&self, seconds: f64, option: SeekOptions) -> Result<(), Error>
pub fn set_loop_file(&self, option: Switch) -> Result<(), Error>
pub fn set_loop_playlist(&self, option: Switch) -> Result<(), Error>
pub fn set_mute(&self, option: Switch) -> Result<(), Error>
Sourcepub fn set_property<T: SetPropertyTypeHandler<T>>(
&self,
property: &str,
value: T,
) -> Result<(), Error>
pub fn set_property<T: SetPropertyTypeHandler<T>>( &self, property: &str, value: T, ) -> Result<(), Error>
§Description
Sets the mpv property
§Supported types
- String
- bool
- f64
- usize
§Input arguments
- property defines the mpv property that should be retrieved
- value defines the value of the given mpv property
§Example
use mpvipc::{Mpv, Error};
fn main() -> Result<(), Error> {
let mpv = Mpv::connect("/tmp/mpvsocket")?;
mpv.set_property("pause", true)?;
Ok(())
}
pub fn set_speed( &self, input_speed: f64, option: NumberChangeOptions, ) -> Result<(), Error>
pub fn set_volume( &self, input_volume: f64, option: NumberChangeOptions, ) -> Result<(), Error>
pub fn stop(&self) -> Result<(), Error>
pub fn toggle(&self) -> Result<(), Error>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mpv
impl RefUnwindSafe for Mpv
impl Send for Mpv
impl Sync for Mpv
impl Unpin for Mpv
impl UnwindSafe for Mpv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more