Struct Player

Source
pub struct Player {
    shared: Arc<Shared>,
    render: Sender<Cmd>,
    audio: Sender<Cmd>,
}

Fields§

§shared: Arc<Shared>§render: Sender<Cmd>§audio: Sender<Cmd>

Implementations§

Source§

impl Player

Source

pub fn new( ctx: Context, backend: Backend, text: Arc<Mutex<TextRasterizer>>, ) -> Self

Source

fn both(&self, c: Cmd)

Source

pub fn set_project(&mut self, project: &Project)

Replace the project (cheap clone; called after every edit). Re-renders the current frame.

Source

pub fn set_backend(&mut self, b: Backend)

Source

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.

Source

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).

Source

pub fn play(&mut self)

Source

pub fn pause(&mut self)

Source

pub fn toggle(&mut self)

Source

pub fn is_playing(&self) -> bool

Source

pub fn time(&self) -> f64

Current timeline time (advances while playing).

Source

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

Clamp to [0, duration] and re-render if paused (keeps playing from t if playing).

Source

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

Newest rendered frame not yet taken (UI uploads it to a texture).

Source

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.

Source

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.

Source

pub fn cache_hits(&self) -> u64

How many frames/layer sets have been served from the RAM cache instead of rendered.

Source

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.

Source

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.

Source

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.

Source

pub fn release_files(&mut self)

Synchronously drop every decoder on both threads (before overwriting a source file).

Trait Implementations§

Source§

impl Drop for Player

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> MaybeSend for T

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,