[][src]Struct libmpv::Mpv

pub struct Mpv {
    pub ctx: NonNull<mpv_handle>,
    // some fields omitted
}

The central mpv context.

Fields

ctx: NonNull<mpv_handle>

The handle to the mpv core

Implementations

impl Mpv[src]

pub fn create_event_context(&self) -> EventContext<'_>[src]

Create a context that can be used to wait for events and control which events are listened for.

Panics

Panics if a context already exists

impl Mpv[src]

pub fn create_protocol_context<T, U>(&self) -> ProtocolContext<'_, T, U> where
    T: RefUnwindSafe,
    U: RefUnwindSafe
[src]

Create a context with which custom protocols can be registered.

Panics

Panics if a context already exists

impl Mpv[src]

pub fn new() -> Result<Mpv>[src]

Create a new Mpv. The default settings can be probed by running: $ mpv --show-profile=libmpv.

pub fn with_initializer<F: FnOnce(MpvInitializer) -> Result<()>>(
    initializer: F
) -> Result<Mpv>
[src]

Create a new Mpv. The same as Mpv::new, but you can set properties before Mpv is initialized.

pub fn load_config(&self, path: &str) -> Result<()>[src]

Load a configuration file. The path has to be absolute, and a file.

pub fn command(&self, name: &str, args: &[&str]) -> Result<()>[src]

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.

pub fn set_property<T: SetData>(&self, name: &str, data: T) -> Result<()>[src]

Set the value of a property.

pub fn get_property<T: GetData>(&self, name: &str) -> Result<T>[src]

Get the value of a property.

pub fn get_internal_time(&self) -> i64[src]

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.

pub fn add_property(&self, property: &str, value: isize) -> Result<()>[src]

Add -or subtract- any value from a property. Over/underflow clamps to max/min.

pub fn cycle_property(&self, property: &str, up: bool) -> Result<()>[src]

Cycle through a given property. up specifies direction. On overflow, set the property back to the minimum, on underflow set it to the maximum.

pub fn multiply_property(&self, property: &str, factor: usize) -> Result<()>[src]

Multiply any property with any positive factor.

pub fn pause(&self) -> Result<()>[src]

Pause playback at runtime.

pub fn unpause(&self) -> Result<()>[src]

Unpause playback at runtime.

pub fn seek_forward(&self, secs: c_double) -> Result<()>[src]

Seek forward relatively from current position in seconds. This is less exact than seek_absolute, see [mpv manual] (https://mpv.io/manual/master/#command-interface- [relative|absolute|absolute-percent|relative-percent|exact|keyframes]).

pub fn seek_backward(&self, secs: c_double) -> Result<()>[src]

See seek_forward.

pub fn seek_absolute(&self, secs: c_double) -> Result<()>[src]

Seek to a given absolute secs.

pub fn seek_percent(&self, percent: isize) -> Result<()>[src]

Seek to a given relative percent position (may be negative). If percent of the playtime is bigger than the remaining playtime, the next file is played. out of bounds values are clamped to either 0 or 100.

pub fn seek_percent_absolute(&self, percent: usize) -> Result<()>[src]

Seek to the given percentage of the playtime.

pub fn seek_revert(&self) -> Result<()>[src]

Revert the previous seek_ call, can also revert itself.

pub fn seek_revert_mark(&self) -> Result<()>[src]

Mark the current position as the position that will be seeked to by seek_revert.

pub fn seek_frame(&self) -> Result<()>[src]

Seek exactly one frame, and pause. Noop on audio only streams.

pub fn seek_frame_backward(&self) -> Result<()>[src]

pub fn screenshot_subtitles(&self, path: Option<&str>) -> Result<()>[src]

"Save the video image, in its original resolution, and with subtitles. Some video outputs may still include the OSD in the output under certain circumstances.".

"[O]ptionally save it to a given file. The format of the file will be guessed by the extension (and --screenshot-format is ignored - the behaviour when the extension is missing or unknown is arbitrary). If the file already exists, it's overwritten. Like all input command parameters, the filename is subject to property expansion as described in Property Expansion."

pub fn screenshot_video(&self, path: Option<&str>) -> Result<()>[src]

"Like subtitles, but typically without OSD or subtitles. The exact behavior depends on the selected video output."

pub fn screenshot_window(&self, path: Option<&str>) -> Result<()>[src]

"Save the contents of the mpv window. Typically scaled, with OSD and subtitles. The exact behaviour depends on the selected video output, and if no support is available, this will act like video.".

pub fn playlist_next_weak(&self) -> Result<()>[src]

Play the next item of the current playlist. Does nothing if the current item is the last item.

pub fn playlist_next_force(&self) -> Result<()>[src]

Play the next item of the current playlist. Terminates playback if the current item is the last item.

pub fn playlist_previous_weak(&self) -> Result<()>[src]

See playlist_next_weak.

pub fn playlist_previous_force(&self) -> Result<()>[src]

See playlist_next_force.

pub fn playlist_load_files(
    &self,
    files: &[(&str, FileState, Option<&str>)]
) -> Result<()>
[src]

The given files are loaded sequentially, returning the index of the current file and the error in case of an error. More information.

Arguments

The files tuple slice consists of: * a string slice - the path * a FileState - how the file will be opened * an optional string slice - any additional options that will be set for this file

Peculiarities

loadfile is kind of asynchronous, any additional option is set during loading, specifics.

pub fn playlist_load_list(&self, path: &str, replace: bool) -> Result<()>[src]

Load the given playlist file, that either replaces the current playlist, or appends to it.

pub fn playlist_clear(&self) -> Result<()>[src]

Remove every, except the current, item from the playlist.

pub fn playlist_remove_current(&self) -> Result<()>[src]

Remove the currently selected item from the playlist.

pub fn playlist_remove_index(&self, position: usize) -> Result<()>[src]

Remove item at position from the playlist.

pub fn playlist_move(&self, old: usize, new: usize) -> Result<()>[src]

Move item old to the position of item new.

pub fn playlist_shuffle(&self) -> Result<()>[src]

Shuffle the playlist.

pub fn subtitle_add_select(
    &self,
    path: &str,
    title: Option<&str>,
    lang: Option<&str>
) -> Result<()>
[src]

Add and select the subtitle immediately. Specifying a language requires specifying a title.

Panics

If a language but not title was specified.

pub fn subtitle_add_auto(
    &self,
    path: &str,
    title: Option<&str>,
    lang: Option<&str>
) -> Result<()>
[src]

See AddSelect. "Don't select the subtitle. (Or in some special situations, let the default stream selection mechanism decide.)".

Returns an Error::InvalidArgument if a language, but not a title, was provided.

Panics

If a language but not title was specified.

pub fn subtitle_add_cached(&self, path: &str) -> Result<()>[src]

See AddSelect. "Select the subtitle. If a subtitle with the same file name was already added, that one is selected, instead of loading a duplicate entry. (In this case, title/language are ignored, and if the [sub] was changed since it was loaded, these changes won't be reflected.)".

pub fn subtitle_remove(&self, index: Option<usize>) -> Result<()>[src]

"Remove the given subtitle track. If the id argument is missing, remove the current track. (Works on external subtitle files only.)"

pub fn subtitle_reload(&self, index: Option<usize>) -> Result<()>[src]

"Reload the given subtitle track. If the id argument is missing, reload the current track. (Works on external subtitle files only.)"

pub fn subtitle_step(&self, skip: isize) -> Result<()>[src]

"Change subtitle timing such, that the subtitle event after the next isize subtitle events is displayed. isize can be negative to step backwards."

pub fn subtitle_seek_forward(&self) -> Result<()>[src]

"Seek to the next subtitle. This is similar to sub-step, except that it seeks video and audio instead of adjusting the subtitle delay. For embedded subtitles (like with matroska), this works only with subtitle events that have already been displayed, or are within a short prefetch range."

pub fn subtitle_seek_backward(&self) -> Result<()>[src]

See SeekForward.

Trait Implementations

impl Drop for Mpv[src]

impl Send for Mpv[src]

impl Sync for Mpv[src]

Auto Trait Implementations

impl RefUnwindSafe for Mpv

impl Unpin for Mpv

impl UnwindSafe for Mpv

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.