pub struct VideoView { /* private fields */ }Expand description
A view that draws a [VideoFrames] stream.
It wakes the window when a frame arrives and draws the newest frame on the next pass.
Implementations§
Source§impl VideoView
impl VideoView
Sourcepub fn new(
ctx: &Context,
name: &str,
frames: impl Into<Option<VideoFrames>>,
render_state: Option<&RenderState>,
) -> Self
pub fn new( ctx: &Context, name: &str, frames: impl Into<Option<VideoFrames>>, render_state: Option<&RenderState>, ) -> Self
Creates a view of frames that draws through render_state.
name names the placeholder texture. A view without frames shows the
placeholder until set_frames gives it some.
§Panics
Panics when called outside a Tokio runtime with frames given.
Sourcepub fn set_frames(&mut self, frames: impl Into<Option<VideoFrames>>)
pub fn set_frames(&mut self, frames: impl Into<Option<VideoFrames>>)
Replaces the stream this view draws, or removes it with None.
The last frame stays on screen until the new stream delivers one.
§Panics
Panics when called outside a Tokio runtime with frames given.
Sourcepub fn render(&mut self) -> Image<'_>
pub fn render(&mut self) -> Image<'_>
Draws the newest frame, if a new one arrived, and returns the image.
Sourcepub fn last_frame(&self) -> Option<&Arc<Frame>>
pub fn last_frame(&self) -> Option<&Arc<Frame>>
Returns the frame render last drew, or None before the first.
A frame that failed to draw still counts, as does one a view without a
renderer skipped. The frame stays after set_frames,
as the picture does.
§Examples
ui.add(view.render());
if let Some(frame) = view.last_frame() {
ui.label(format!("{} at {:?}", frame.size(), frame.timestamp));
}Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for VideoView
impl !UnwindSafe for VideoView
impl Freeze for VideoView
impl Send for VideoView
impl Sync for VideoView
impl Unpin for VideoView
impl UnsafeUnpin for VideoView
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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