#[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: VideoConfigSource URL + autoplay/loop + format.
on_frame: OptionOnVideoFrameOptional per-frame user hook (effects / save / send - azul-meet).
frames: OptionRefAnyOptional 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
impl VideoWidget
Sourcepub const fn create(config: VideoConfig) -> Self
pub const fn create(config: VideoConfig) -> Self
Create a video widget for the given config.
Sourcepub fn set_on_frame<C: Into<OnVideoFrameCallback>>(
&mut self,
data: RefAny,
on_frame: C,
)
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).
Sourcepub fn with_on_frame<C: Into<OnVideoFrameCallback>>(
self,
data: RefAny,
on_frame: C,
) -> Self
pub fn with_on_frame<C: Into<OnVideoFrameCallback>>( self, data: RefAny, on_frame: C, ) -> Self
Builder form of set_on_frame.
Sourcepub fn with_frames(self, frames: RefAny) -> Self
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.
Sourcepub fn dom(self) -> Dom
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.
Sourcepub fn dom_with_decoder(self, cb: ThreadCallback) -> Dom
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§
Auto Trait Implementations§
impl Freeze for VideoWidget
impl RefUnwindSafe for VideoWidget
impl Send for VideoWidget
impl Sync for VideoWidget
impl Unpin for VideoWidget
impl UnsafeUnpin for VideoWidget
impl UnwindSafe for VideoWidget
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
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