duck.html.components.video¶
Video HTML Component.
This module provides a customizable Video component for embedding video content into HTML.
Arguments:
source (str, required): The source URL of the video. This is the path to the video file or external URL.
alt (str, optional): A text description for the video. It serves as an alternative when the video cannot be played.
width (str, optional): Specifies the width of the video element in pixels (or percentage).
height (str, optional): Specifies the height of the video element in pixels (or percentage).
autoplay (bool, optional): Indicates if the video should automatically play when loaded. Defaults to
False.loop (bool, optional): Specifies if the video should loop when finished. Defaults to
False.muted (bool, optional): Determines whether the video should be muted by default. Defaults to
False.playsinline (bool, optional): Allows the video to play inline on mobile devices (i.e., not in full-screen mode). Defaults to
False.
Example Usage:
video = Video(
source="path/to/video.mp4",
alt="A sample video",
width="800px",
height="450px",
autoplay=True,
loop=True,
muted=False,
playsinline=True
)
component.add_child(video)
Module Contents¶
Classes¶
HTML Video component. |
API¶
- class duck.html.components.video.Video(element: Optional[str] = None, properties: Optional[Dict[str, str]] = None, props: Optional[Dict[str, str]] = None, style: Optional[Dict[str, str]] = None, inner_html: Optional[Union[str, str, float]] = None, children: Optional[List[duck.html.components.HtmlComponent]] = None, **kwargs)[source]¶
Bases:
duck.html.components.InnerComponentHTML Video component.
- Parameters:
source – Video source url
alt – Video alternative text
width – Video width
height – Video height
autoplay – Whether to autoplay video
loop – Whether to loop video
muted – Whether to mute video
playsinline – Whether to turn on playsinline
Initialization
Initialize an HTML component.
- Parameters:
element – The HTML element tag name (e.g., textarea, input, button). Can be None, but make sure element is returned by get_element method.
accept_inner_html – Whether the HTML component accepts an inner body (e.g., inner-body-here).
inner_html – Inner html to add to the HTML component. Defaults to None.
properties – Dictionary for properties to initialize the component with.
props – Just same as properties argument (added for simplicity).
style – Dictionary for style to initialize the component with.
**kwargs – Extra keyword arguments
- Raises:
HtmlComponentError – If ‘element’ is not a string or ‘inner_html’ is set but ‘accept_inner_html’ is False.