Struct MpvHandlerBuilder

Source
pub struct MpvHandlerBuilder { /* private fields */ }

Implementations§

Source§

impl MpvHandlerBuilder

A must-use MpvHandler builder.

  • Step 1 : call MpvHandler::new() to create a Builder.
  • Step 2 : Add options to your player
  • Step 3 : Finish creating your MpvHandler, either with build() or build_with_gl(...)
Source

pub fn new() -> Result<Self>

Returns a std::Result that contains an MpvHandlerBuilder if successful, or an Error is the creation failed. Currently, errors can happen in the following situations : - out of memory - LC_NUMERIC is not set to “C” (see general remarks)

Source

pub fn set_option<T: MpvFormat>( &mut self, property: &str, option: T, ) -> Result<()>

All options for your mpv player should be set on this step

§Example
let mut mpv_builder = mpv::MpvHandlerBuilder::new().expect("Failed to init MPV builder");
mpv_builder.set_option("sid","no").expect("Failed to set option 'sid' to 'no'");
// set other options
// Build the MpvHandler later
Source

pub fn try_hardware_decoding(&mut self) -> Result<()>

shortcut for set_option("hwdec","auto")

If it is available, the playing will try hardware decoding

Source

pub fn build(self) -> Result<MpvHandler>

Finish creating your player. It will spawn a new window on your window manager. Note that it returns a Box of MpvHandler because it needs to be allocated on the heap; The Rust MpvHandler gives its own pointer the the C mpv API, and moving the MpvHandler within the stack is forbidden in that case.

Source

pub fn build_with_gl( self, get_proc_address: mpv_opengl_cb_get_proc_address_fn, get_proc_address_ctx: *mut c_void, ) -> Result<Box<MpvHandlerWithGl>>

Finish creating your player, using a custom opengl instance. It will not spawn a new, window on your window manager, but instead use the given opengl context to draw the video.

An option of an ‘extern “C”’ function must be passed as a parameter, which fullfills the role of get_proc_address. An arbitrary opaque user context which will be passed to the get_proc_address callback must also be sent.

§Errors
  • MPV_ERROR_UNSUPPORTED: the OpenGL version is not supported (or required extensions are missing)

For additional information, see examples/sdl2.rs for a basic implementation with a sdl2 opengl context

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.