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ยถ

Video

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.InnerComponent

HTML 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.

get_element()[source]ยถ
on_create()[source]ยถ