pub struct Player {
shared: Arc<Shared>,
render: Sender<Cmd>,
audio: Sender<Cmd>,
}Fields§
§render: Sender<Cmd>§audio: Sender<Cmd>Implementations§
Source§impl Player
impl Player
pub fn new( ctx: Context, backend: Backend, text: Arc<Mutex<TextRasterizer>>, ) -> Self
fn both(&self, c: Cmd)
Sourcepub fn set_project(&mut self, project: &Project)
pub fn set_project(&mut self, project: &Project)
Replace the project (cheap clone; called after every edit). Re-renders the current frame.
pub fn set_backend(&mut self, b: Backend)
Sourcepub fn set_gpu(&mut self, on: bool)
pub fn set_gpu(&mut self, on: bool)
GPU preview: the render thread publishes decoded layers (take_layers) instead of a composited
frame. Switching back to false resumes the CPU compositor on the next render.
Sourcepub fn set_canvas(&mut self, w: u32, h: u32, max_width: u32)
pub fn set_canvas(&mut self, w: u32, h: u32, max_width: u32)
Preview canvas size in pixels (the Player clamps width to max_width, keeping aspect).
pub fn play(&mut self)
pub fn pause(&mut self)
pub fn toggle(&mut self)
pub fn is_playing(&self) -> bool
Sourcepub fn seek(&mut self, t: f64)
pub fn seek(&mut self, t: f64)
Clamp to [0, duration] and re-render if paused (keeps playing from t if playing).
Sourcepub fn take_frame(&mut self) -> Option<Arc<Frame>>
pub fn take_frame(&mut self) -> Option<Arc<Frame>>
Newest rendered frame not yet taken (UI uploads it to a texture).
Sourcepub fn take_layers(&mut self) -> Option<Arc<LayerSet>>
pub fn take_layers(&mut self) -> Option<Arc<LayerSet>>
GPU mode only: the newest decoded layers not yet taken (the UI renders them with engine::gpu).
Always None while the CPU compositor is running.
Sourcepub fn is_buffering(&self) -> bool
pub fn is_buffering(&self) -> bool
True while the render thread has fallen behind decode and is refilling its read-ahead. The UI pauses the clock (audio too) and shows a spinner until this clears.
Sourcepub fn cache_hits(&self) -> u64
pub fn cache_hits(&self) -> u64
How many frames/layer sets have been served from the RAM cache instead of rendered.
Sourcepub fn render_once(&self, t: f64, max_w: u32) -> Option<Arc<Frame>>
pub fn render_once(&self, t: f64, max_w: u32) -> Option<Arc<Frame>>
Synchronously render the timeline at t, at most max_w px wide (project aspect kept), on the
render thread (its decoders stay warm). None if the thread is gone or takes longer than 3 s.
Not a hot path (MCP render.frame tool): allocates a fresh frame per call.
Sourcepub fn layers_once(&self, t: f64, max_w: u32) -> Option<Arc<LayerSet>>
pub fn layers_once(&self, t: f64, max_w: u32) -> Option<Arc<LayerSet>>
Synchronously decode the layers at t (at most max_w px wide) on the render thread, for a
one-off GPU render on the UI thread (export-frame, MCP tools). None if it takes longer than 3 s.
Sourcepub fn set_proxies(&mut self, map: HashMap<String, String>)
pub fn set_proxies(&mut self, map: HashMap<String, String>)
Swap the preview proxy map (source path -> proxy file). Video only: the render thread’s pool re-resolves every decode through it; audio always reads the originals.
Sourcepub fn release_files(&mut self)
pub fn release_files(&mut self)
Synchronously drop every decoder on both threads (before overwriting a source file).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Player
impl RefUnwindSafe for Player
impl Send for Player
impl Sync for Player
impl Unpin for Player
impl UnwindSafe for Player
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
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more