pub struct MoviePlayer<'a> { /* private fields */ }Expand description
Plays a movie back, feeding its recorded inputs into an emulator one frame at a time.
Usage (caller-driven; the player applies set_buttons, the caller runs
the frame):
ⓘ
movie.seek_to_start(&mut nes)?;
let mut player = MoviePlayer::new(&movie);
while player.apply_next(&mut nes) {
nes.run_frame();
}Implementations§
Source§impl<'a> MoviePlayer<'a>
impl<'a> MoviePlayer<'a>
Sourcepub const fn cursor(&self) -> usize
pub const fn cursor(&self) -> usize
Index of the frame that Self::apply_next will apply next.
Sourcepub const fn is_finished(&self) -> bool
pub const fn is_finished(&self) -> bool
true if every frame has been played.
Sourcepub fn peek(&self) -> Option<FrameInput>
pub fn peek(&self) -> Option<FrameInput>
Peek the next frame’s input without advancing.
Sourcepub fn apply_next(&mut self, nes: &mut Nes) -> bool
pub fn apply_next(&mut self, nes: &mut Nes) -> bool
Apply the next frame’s recorded input to nes via set_buttons and
advance the cursor. Returns false (without applying anything) once
the movie is exhausted — the caller stops its replay loop on false.
Call this before Nes::run_frame, mirroring the record-side
capture ordering, so the same inputs are applied to the same frame.
Sourcepub const fn rewind(&mut self)
pub const fn rewind(&mut self)
Reset the cursor back to frame 0 (the caller is responsible for
re-seeking nes via Movie::seek_to_start).
Trait Implementations§
Source§impl<'a> Clone for MoviePlayer<'a>
impl<'a> Clone for MoviePlayer<'a>
Source§fn clone(&self) -> MoviePlayer<'a>
fn clone(&self) -> MoviePlayer<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for MoviePlayer<'a>
impl<'a> RefUnwindSafe for MoviePlayer<'a>
impl<'a> Send for MoviePlayer<'a>
impl<'a> Sync for MoviePlayer<'a>
impl<'a> Unpin for MoviePlayer<'a>
impl<'a> UnsafeUnpin for MoviePlayer<'a>
impl<'a> UnwindSafe for MoviePlayer<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more