Skip to main content

PlaybackController

Struct PlaybackController 

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

Implementations§

Source§

impl PlaybackController

Source

pub fn get_frame_no(&self) -> f32

Source

pub fn is_end_frame_reached(&self) -> bool

true while the last frame of a cycle is being shown. With a finite loop count this is raised once per cycle, not only on the last one, and with an infinite loop count it is never raised.

Internal playback state, absent from the C-API and the WASM bindings. A finished notification reads is_finished.

Source

pub fn is_finished(&self) -> bool

true once the configured loops have completed, and sticky until the next play / setup. Never becomes true under an infinite loop count, nor after a bare stop() part-way through playback.

remain_loops only reaches 0 on the branch that ends playback, so this cannot be confused with stop() being called while the last frame of a non-final cycle happens to be showing.

Source

pub fn just_looped(&self) -> bool

true for the single update that took the playhead back to the start of its cycle. Cleared on entry to every update, so it must be polled after each one or the pulse is lost. Never raised on the final cycle of a finite loop count — that cycle finishes instead of looping.

Source

pub fn is_playing(&self) -> bool

Source

pub fn is_pausing(&self) -> bool

Source

pub fn get_skip_frames(&self) -> bool

Source

pub fn is_playing_forward(&self) -> bool

Source

pub fn get_playback_direction(&self) -> PlaybackDirection

Source

pub fn get_playback_style(&self) -> PlaybackStyle

Source

pub fn get_loop_count(&self) -> i32

Source

pub fn get_remaining_loops(&self) -> i32

Source

pub fn get_start_frame(&self) -> i32

Source

pub fn get_end_frame(&self) -> i32

Source

pub fn get_anime_data_start_frame(&self) -> i32

The bound animation’s own range, which set_animation_section never touches. get_start_frame / get_end_frame report the section, so a caller that computes a section from them feeds its own last narrowing back in.

Source

pub fn get_anime_data_end_frame(&self) -> i32

Source

pub fn get_frame_rate(&self) -> i32

Source

pub fn get_speed_scale(&self) -> f32

The playback speed in effect, as a multiple of Self::get_frame_rate.

This is what Self::set_speed_scale stored, not what it was handed: a negative rate clamps to 0.0 on the way in, so a host that reads this back sees the stop it actually got.

Source

pub fn get_passed_frames(&self) -> &[i32]

Source§

impl PlaybackController

Source

pub fn new() -> Self

Source

pub fn reset_setup(&mut self)

Source

pub fn setup(&mut self, start_frame: i32, end_frame: i32, fps: i32)

Binds a new animation to this source.

What resets and what survives is deliberate, and the line is who sets it. A Player’s state machine calls this on every transition, so anything the transition itself specifies is reset — otherwise state N’s behaviour would depend on state N-1, and a loops = 1 meant for an attack would quietly follow the character into its walk. That covers the section (frame indices mean nothing against a different clip) and the loop count.

The speed, the frame-rate override, the frame skip and the direction / style survive, because a different system sets them: a slow-motion effect, a haste buff, a “show every frame” capture mode. Resetting those here would let an animation transition clobber a setting the state machine never knew about. The Players’ sub-frame flag is the same kind of setting, on their side of the FFI.

Self::reset_setup does reset them: it releases the slot for a different owner, rather than handing the same one a new clip.

Source

pub fn set_skip_frames(&mut self, skip: bool)

Source

pub fn set_loop_count(&mut self, loops: i32)

Set the number of loops. n > 0: play n cycles, then stop -1: infinite loop 0: infinite loop (accepted as a synonym for -1)

0 and every negative value normalize to -1 so that update and resolve_frame agree on the infinite sentinel.

Source

pub fn set_frame_rate(&mut self, frame_rate: i32)

Overrides the rate the clip was authored at. 0 or any negative value clears the override, handing playback back to the authored rate.

This is an absolute rate — “this player runs at n fps” — where Self::set_speed_scale is a multiple of whatever the clip was authored at. Both are the host’s, so both survive setup.

Source

pub fn set_playback_direction( &mut self, direction: PlaybackDirection, style: PlaybackStyle, )

Set playback direction and playback style. Execute the function before calling play().

Source

pub fn set_speed_scale(&mut self, speed_scale: f32)

Sets the playback speed as a multiple of the effective frame rate.

0.0 stops the playhead where it stands, rather than meaning “no setting”: time passes, is_playing stays true, and nothing advances. That matches what a host means by a zero time scale, and what engine animation players do with one.

A negative rate is not reverse playback — direction is Self::set_playback_direction’s business — and is clamped to a stop.

Source

pub fn set_animation_section( &mut self, start_frame: i32, end_frame: i32, ) -> bool

Narrows playback to [start_frame, end_frame], both ends included, so a section whose ends are one frame plays that frame. An end outside the animation’s own range (-1, say) is the animation’s edge on that side.

Returns false, changing nothing, when both ends are in range and the end is before the start: no section runs backwards.

Source

pub fn update(&mut self, delta: f32) -> f32

Source§

impl PlaybackController

Source

pub fn play(&mut self)

Source

pub fn play_with_start_frame(&mut self, frame_no: f32)

Source

pub fn pause(&mut self)

Holds playback where it stands. Idempotent: pausing an already-paused animation leaves it paused. is_playing stays true — a pause is a hold, not a stop — so a caller telling the two apart reads Self::is_pausing. Use Self::resume to lift the hold; play rewinds and is not a resume.

Ignored when nothing is playing, so “stopped, and also paused” cannot happen and is_pausing can be read on its own.

Source

pub fn resume(&mut self)

Lifts the hold set by Self::pause, carrying on from the frame it stopped at. Idempotent, and a no-op on an animation that was never paused. Does not start a stopped animation — that is play’s job.

Source

pub fn stop(&mut self)

Ends playback. The playhead stays where it stands — nothing rewinds — so the host keeps drawing the frame it stopped on. Seek, or play, to move it.

Source

pub fn set_frame_no(&mut self, frame: f32)

Source

pub fn set_frame_relative(&mut self, diff: f32)

Sets current_frame to the position reached after diff frames have elapsed since playback started, with the configured start_frame / end_frame / loops / playback_style / playback_direction applied. diff should already incorporate per-instance speed (i.e. diff = (parent_frame - event_frame) * speed).

Unlike update(delta) this is a deterministic, non-incremental computation — the same diff always produces the same frame, which is what allows parent-driven seek / reverse / frame-skip on Instance parts to render correctly.

Source

pub fn next_frame(&mut self)

Set the current frame to the next frame. The function ignores direction and style.

Source

pub fn prev_frame(&mut self)

Set the current frame to the previous frame. The function ignores direction and style.

Trait Implementations§

Source§

impl Default for PlaybackController

Source§

fn default() -> Self

Returns the “default value” for a type. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more