Skip to main content

Video

Struct Video 

Source
pub struct Video { /* private fields */ }
Expand description

Video widget (state, layout and draw commands).

Implementations§

Source§

impl Video

Source

pub fn new(src: impl Into<String>) -> Self

Create a new video with a source.

Source

pub fn poster(self, url: impl Into<String>) -> Self

Set the poster image.

Source

pub fn alt(self, alt: impl Into<String>) -> Self

Set the alt text.

Source

pub fn width(self, width: f32) -> Self

Set the intrinsic width.

Negative values become 0 and values above 1e15 are clamped to it; NaN and infinities count as “not set”, so measure falls back to the default width instead of reporting a non-finite size.

Source

pub fn height(self, height: f32) -> Self

Set the intrinsic height (same rules as Video::width).

Source

pub fn size(self, width: f32, height: f32) -> Self

Set both width and height.

Source

pub fn accessible_name(self, name: impl Into<String>) -> Self

Set the accessible name.

Source

pub fn test_id(self, id: impl Into<String>) -> Self

Set the test ID.

Source

pub const fn autoplay(self, autoplay: bool) -> Self

Set autoplay; the video starts Playing when true, Paused when false.

Source

pub const fn controls(self, controls: bool) -> Self

Set whether the controls are shown.

Source

pub fn get_src(&self) -> &str

Get the source.

Source

pub fn get_poster(&self) -> Option<&str>

Get the poster URI.

Source

pub fn get_alt(&self) -> &str

Get the alt text.

Source

pub fn get_width(&self) -> Option<f32>

Get the intrinsic width.

Source

pub fn get_height(&self) -> Option<f32>

Get the intrinsic height.

Source

pub const fn is_autoplay(&self) -> bool

Whether autoplay is set.

Source

pub const fn has_controls(&self) -> bool

Whether controls are shown.

Source

pub const fn state(&self) -> VideoState

Get the playback state.

Source

pub const fn is_playing(&self) -> bool

Whether the video is playing.

Source

pub fn play(&mut self)

Start (or restart) playback.

Source

pub fn pause(&mut self)

Pause playback. A video that has already ended stays Ended.

Source

pub fn toggle(&mut self)

Toggle between playing and not playing.

Source

pub fn ended(&mut self)

Mark playback as having reached the end.

Source

pub fn play_glyph(&self) -> [Point; 3]

The three vertices of the play glyph, centred in the laid-out bounds.

The bounding box of the triangle has the same centre as the bounds. Every vertex is finite and inside the sanitised laid-out bounds, whatever rectangle was passed to layout.

Trait Implementations§

Source§

impl Brick for Video

Source§

fn brick_name(&self) -> &'static str

Get the brick’s unique type name
Source§

fn assertions(&self) -> &[BrickAssertion]

Get all assertions for this brick
Source§

fn budget(&self) -> BrickBudget

Get the performance budget
Source§

fn verify(&self) -> BrickVerification

Verify all assertions against current state Read more
Source§

fn to_html(&self) -> String

Generate HTML for this brick (WASM target) Read more
Source§

fn to_css(&self) -> String

Generate CSS for this brick (WASM target) Read more
Source§

fn test_id(&self) -> Option<&str>

Get the test ID for DOM queries
Source§

fn can_render(&self) -> bool

Check if this brick can be rendered (all assertions pass)
Source§

impl Clone for Video

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Video

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Video

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Video

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Video

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Widget for Video

Source§

fn layout(&mut self, bounds: Rect) -> LayoutResult

Lay the video out in bounds.

The bounds are stored as given, so verify can judge them (like Grid and Waveform). They are sanitised where they are used (NaN and infinities become 0, components are clamped to +-1e15, a negative size becomes 0), so every rect and glyph vertex paint emits is finite and the returned size is finite and not negative.

Source§

fn type_id(&self) -> TypeId

Get the type identifier for this widget type.
Source§

fn measure(&self, constraints: Constraints) -> Size

Compute intrinsic size constraints.
Source§

fn paint(&self, canvas: &mut dyn Canvas)

Generate draw commands for rendering. Read more
Source§

fn event(&mut self, event: &Event) -> Option<Box<dyn Any + Send>>

Handle input events.
Source§

fn children(&self) -> &[Box<dyn Widget>]

Get child widgets for tree traversal.
Source§

fn children_mut(&mut self) -> &mut [Box<dyn Widget>]

Get mutable child widgets.
Source§

fn is_interactive(&self) -> bool

Check if this widget is interactive (can receive focus/events).
Source§

fn is_focusable(&self) -> bool

Check if this widget can receive keyboard focus.
Source§

fn accessible_name(&self) -> Option<&str>

Get the accessible name for screen readers.
Source§

fn accessible_role(&self) -> AccessibleRole

Get the accessible role.
Source§

fn bounds(&self) -> Rect

Get the current bounds of this widget.
Source§

fn test_id(&self) -> Option<&str>

Get the test ID for this widget (if any).

Auto Trait Implementations§

§

impl Forget for Video

§

impl Freeze for Video

§

impl Move for Video

§

impl RefUnwindSafe for Video

§

impl Send for Video

§

impl Sync for Video

§

impl Unpin for Video

§

impl UnsafeUnpin for Video

§

impl UnwindSafe for Video

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> BrickWidgetExt for T
where T: Brick,

Source§

fn verify_for_render(&self) -> Result<(), String>

Verify this brick before rendering. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.