pub struct PlaybackController { /* private fields */ }Implementations§
Source§impl PlaybackController
impl PlaybackController
pub fn get_frame_no(&self) -> f32
Sourcepub fn is_end_frame_reached(&self) -> bool
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.
Sourcepub fn is_finished(&self) -> bool
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.
Sourcepub fn just_looped(&self) -> bool
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.
pub fn is_playing(&self) -> bool
pub fn is_pausing(&self) -> bool
pub fn get_skip_frames(&self) -> bool
pub fn is_playing_forward(&self) -> bool
pub fn get_playback_direction(&self) -> PlaybackDirection
pub fn get_playback_style(&self) -> PlaybackStyle
pub fn get_loop_count(&self) -> i32
pub fn get_remaining_loops(&self) -> i32
pub fn get_start_frame(&self) -> i32
pub fn get_end_frame(&self) -> i32
Sourcepub fn get_anime_data_start_frame(&self) -> i32
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.
pub fn get_anime_data_end_frame(&self) -> i32
pub fn get_frame_rate(&self) -> i32
Sourcepub fn get_speed_scale(&self) -> f32
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.
pub fn get_passed_frames(&self) -> &[i32]
Source§impl PlaybackController
impl PlaybackController
pub fn new() -> Self
pub fn reset_setup(&mut self)
Sourcepub fn setup(&mut self, start_frame: i32, end_frame: i32, fps: i32)
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.
pub fn set_skip_frames(&mut self, skip: bool)
Sourcepub fn set_loop_count(&mut self, loops: i32)
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.
Sourcepub fn set_frame_rate(&mut self, frame_rate: i32)
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.
Sourcepub fn set_playback_direction(
&mut self,
direction: PlaybackDirection,
style: PlaybackStyle,
)
pub fn set_playback_direction( &mut self, direction: PlaybackDirection, style: PlaybackStyle, )
Set playback direction and playback style. Execute the function before calling play().
Sourcepub fn set_speed_scale(&mut self, speed_scale: f32)
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.
Sourcepub fn set_animation_section(
&mut self,
start_frame: i32,
end_frame: i32,
) -> bool
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.
pub fn update(&mut self, delta: f32) -> f32
Source§impl PlaybackController
impl PlaybackController
pub fn play(&mut self)
pub fn play_with_start_frame(&mut self, frame_no: f32)
Sourcepub fn pause(&mut self)
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.
Sourcepub fn resume(&mut self)
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.
Sourcepub fn stop(&mut self)
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.
pub fn set_frame_no(&mut self, frame: f32)
Sourcepub fn set_frame_relative(&mut self, diff: f32)
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.
Sourcepub fn next_frame(&mut self)
pub fn next_frame(&mut self)
Set the current frame to the next frame. The function ignores direction and style.
Sourcepub fn prev_frame(&mut self)
pub fn prev_frame(&mut self)
Set the current frame to the previous frame. The function ignores direction and style.