VideoPlayer

Struct VideoPlayer 

Source
pub struct VideoPlayer<Api: Api = Default, const FREE_ON_DROP: bool = true>(/* private fields */);

Implementations§

Source§

impl<Api: Api + Copy> VideoPlayer<Api, true>

Source

pub fn into_shared(self) -> VideoPlayer<Api, false>

Convert this video player into the same but that will not be freed on drop. That means that only C-part of the player will not be freed.

Safety is guaranteed by the caller.

Source§

impl<Api: Api> VideoPlayer<Api, true>

Source

pub fn load<P: AsRef<Path>>(path: P) -> Result<Self, ApiError>
where Api: Default,

Opens the pdv file at path and returns a new video player object for rendering its frames.

Calls sys::ffi::playdate_video::loadVideo.

Source

pub fn load_with<P: AsRef<Path>>(api: Api, path: P) -> Result<Self, ApiError>

Opens the pdv file at path and returns a new video player object for rendering its frames.

Calls sys::ffi::playdate_video::loadVideo.

Source§

impl<Api: Api, const FOD: bool> VideoPlayer<Api, FOD>

Source

pub fn set_context<'a, 'b: 'a>( &'a self, bitmap: &'b impl AnyBitmap, ) -> Result<(), Error>

Sets the rendering destination for the video player to the given bitmap.

If the function fails, it returns Error::Video if err-message supplied by C-API, or Error::Unknown in other cases.

Calls sys::ffi::playdate_video::setContext.

Source

pub fn get_context(&self) -> Result<BitmapRef<'_>, Error>

Gets the rendering destination for the video player.

If no rendering context has been set allocates a context bitmap with the same dimensions as the video will be allocated.

Calls sys::ffi::playdate_video::getContext.

Source

pub fn use_screen_context(&self)

Source

pub fn render_frame(&self, n: c_int) -> Result<(), Error>

Renders frame number n into the current context.

In case of error, it returns Error::Video if err-message supplied by C-API, or Error::Unknown in other cases.

Calls sys::ffi::playdate_video::renderFrame.

Source

pub fn info(&self) -> VideoPlayerOutInfo

Retrieves information about the video.

Calls sys::ffi::playdate_video::renderFrame.

Source

pub fn info_to(&self, info: &mut VideoPlayerOutInfo)

Retrieves information about the video, by passing values into given info.

Calls sys::ffi::playdate_video::renderFrame.

Source

pub fn info_raw( &self, width: Option<&mut c_int>, height: Option<&mut c_int>, frame_rate: Option<&mut c_float>, frame_count: Option<&mut c_int>, current_frame: Option<&mut c_int>, )

Retrieves information about the video, by passing optional mutable references.

Example:

let mut frame_count = Some(0);
let mut current_frame = Some(0);
player.info_raw(None, None, None,
                frame_count.as_mut(),
                current_frame.as_mut()
               );
println!( "{}/{}", current_frame.unwrap(), frame_count.unwrap());

Calls sys::ffi::playdate_video::renderFrame.

Source

pub fn get_error(&self) -> Option<Error>

Returns Error with text describing the most recent error.

Inner text is borrowed by C, so it should be used immediately or converted to something owned.

See also VideoPlayer::get_error_cstr.

Calls sys::ffi::playdate_video::getError.

Source

pub fn get_error_cstr(&self) -> Option<&CStr>

Returns [CStr] describing the most recent error.

String-slice is borrowed by C, so it should be used immediately or converted to something owned.

Calls sys::ffi::playdate_video::getError.

Trait Implementations§

Source§

impl<Api: Debug + Api, const FREE_ON_DROP: bool> Debug for VideoPlayer<Api, FREE_ON_DROP>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Api: Api, const FOD: bool> Drop for VideoPlayer<Api, FOD>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<Api, const FREE_ON_DROP: bool> Freeze for VideoPlayer<Api, FREE_ON_DROP>
where Api: Freeze,

§

impl<Api, const FREE_ON_DROP: bool> RefUnwindSafe for VideoPlayer<Api, FREE_ON_DROP>
where Api: RefUnwindSafe,

§

impl<Api = Default, const FREE_ON_DROP: bool = true> !Send for VideoPlayer<Api, FREE_ON_DROP>

§

impl<Api = Default, const FREE_ON_DROP: bool = true> !Sync for VideoPlayer<Api, FREE_ON_DROP>

§

impl<Api, const FREE_ON_DROP: bool> Unpin for VideoPlayer<Api, FREE_ON_DROP>
where Api: Unpin,

§

impl<Api, const FREE_ON_DROP: bool> UnwindSafe for VideoPlayer<Api, FREE_ON_DROP>
where Api: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.