Skip to main content

VideoWidget

Struct VideoWidget 

Source
#[repr(C)]
pub struct VideoWidget { pub config: VideoConfig, pub on_frame: OptionOnVideoFrame, pub frames: OptionRefAny, }
Expand description

A video-playback widget. create(config).dom() yields an <img> the decode thread keeps fed.

Fields§

§config: VideoConfig

Source URL + autoplay/loop + format.

§on_frame: OptionOnVideoFrame

Optional per-frame user hook (effects / save / send - azul-meet).

§frames: OptionRefAny

Optional pre-decoded frames to replay (a RefAny holding a Vec<VideoFrame>); set via with_frames. When present the widget cycles these instead of the test pattern.

Implementations§

Source§

impl VideoWidget

Source

pub const fn create(config: VideoConfig) -> Self

Create a video widget for the given config.

Source

pub fn set_on_frame<C: Into<OnVideoFrameCallback>>( &mut self, data: RefAny, on_frame: C, )

Set a hook invoked with every decoded frame - for live effects, saving frames into your data model, or sending them over the network (azul-meet). The backreference DI pattern (see architecture.md).

Source

pub fn with_on_frame<C: Into<OnVideoFrameCallback>>( self, data: RefAny, on_frame: C, ) -> Self

Builder form of set_on_frame.

Source

pub fn with_frames(self, frames: RefAny) -> Self

Replay a list of already-decoded frames instead of the built-in test pattern: frames is a RefAny holding a Vec<VideoFrame>. The background worker cycles them through the shared GL presenter (the same present_frame path the camera/screencap widgets use), so callers that decode a clip up front (e.g. decode_mp4_h264_bytes) get real pixels on screen. The RefAny must carry a Vec<VideoFrame>, else playback is skipped and the test pattern shows instead.

Source

pub fn dom(self) -> Dom

Build the widget’s DOM: a single <img> node a background thread keeps fed. Replays pre-decoded with_frames if given, else shows the built-in test pattern.

Source

pub fn dom_with_decoder(self, cb: ThreadCallback) -> Dom

Build the widget’s DOM and wire a background streaming decode worker - mirrors MapWidget::dom_with_fetch. cb runs on a framework Thread OFF the main thread: it reads the VideoConfig (its typed VideoSource - URL / file / bytes), runs the VK decode incrementally (no up-front decode), and WriteBacks frames to the <img> paced by wall-clock (dropping late frames). The standard worker is azul_dll::desktop::extra::video_codec::stream::video_decode_worker; wrap it in a ThreadCallback to pass it here.

Trait Implementations§

Source§

impl Debug for VideoWidget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.