Struct mpv::MpvHandlerBuilder [] [src]

pub struct MpvHandlerBuilder {
    // some fields omitted
}

Methods

impl MpvHandlerBuilder
[src]

A must-use MpvHandler Builder.

  • Step 1 : call 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(...)

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)

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

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.

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