Skip to main content

Player

Struct Player 

Source
pub struct Player { /* private fields */ }
Expand description

A playing file. Lives on the thread that draws it; dropping it stops the workers and ends its AudioOut.

Implementations§

Source§

impl Player

Source

pub fn open(path: &Path, audio: bool) -> Result<(Player, Option<AudioOut>)>

Opens path paused at the start. With audio, the file’s sound is decoded and the returned AudioOut must be played for the clock to run; without, it plays silent on the wall clock.

Source

pub fn open_preview( path: &Path, audio: bool, max_side: u32, ) -> Result<(Player, Option<AudioOut>)>

As Player::open, for a small preview: pictures fit max_side on their long side, and dropping it never waits for the workers, which stop after the packet they are on. Opening reads and probes the file, so it may take a moment; call it off the UI thread (a Player and its AudioOut can be sent to the thread that draws).

Source

pub fn info(&self) -> &Info

Source

pub fn is_ready(&self) -> bool

The first picture is decoded (or there is none to wait for).

Source

pub fn play(&mut self)

Plays at the current speed; from the end, plays from the start.

Source

pub fn pause(&mut self)

Source

pub fn toggle(&mut self)

Source

pub fn is_playing(&self) -> bool

Source

pub fn seek(&mut self, secs: f64)

Jumps to secs (clamped to the clip): the keyframe before it is found and decoded forward to the frame at secs.

Source

pub fn step(&mut self, frames: i32)

Moves frames frames forwards (or backwards when negative) and pauses. Forward steps take the next decoded frames; backward steps seek to the earlier frame.

Source

pub fn rate(&self) -> f32

Source

pub fn set_rate(&mut self, rate: f32)

Changes the speed. The sound is stretched to match and keeps its pitch, as preservesPitch does in Eagle’s <video>, so the queued sound is decoded again from here.

Source

pub fn set_volume(&mut self, volume: f32)

0..=1.

Source

pub fn set_muted(&mut self, muted: bool)

Muting stops decoding the sound and runs the picture on the wall clock; unmuting decodes it again from the playhead.

Source

pub fn set_looping(&mut self, looping: bool)

Source

pub fn looping(&self) -> bool

Source

pub fn current_time(&self) -> f64

The playhead in seconds.

Source

pub fn tick(&mut self)

Call every frame: at the end of the clip, starts again from the top when looping, or stops.

Source

pub fn frame(&mut self) -> Option<Frame>

The frame due now, if it differs from the last one handed out.

Source

pub fn current_frame(&self) -> Result<Frame>

The picture at the playhead at the clip’s full size, decoded afresh so playback is not disturbed.

Trait Implementations§

Source§

impl Drop for Player

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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.