Class Video


@Marshalled(typeName="video") public class Video extends HtmlElementMixed<Video>
DTO for an HTML <video> element.

The video element is used to embed video content in an HTML document. It provides a way to include video files that can be played by the browser's built-in video player. The video element supports multiple video formats and provides various attributes for controlling playback, appearance, and behavior. It can contain source elements to specify multiple video formats for browser compatibility.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Simple video with controls Video simple = video() .src("movie.mp4") .controls(true) .width(640) .height(360); // Video with multiple sources Video multiple = video( source().src("movie.mp4").type("video/mp4"), source().src("movie.webm").type("video/webm"), source().src("movie.ogg").type("video/ogg") ).controls(true); // Autoplay video (muted for browser compatibility) Video autoplay = video() .src("intro.mp4") .autoplay(true) .muted(true) .loop(true); // Video with poster image Video poster = video() .src("trailer.mp4") .poster("trailer-poster.jpg") .controls(true) .width(800) .height(450); // Video with custom styling Video styled = video() .src("presentation.mp4") .controls(true) .class_("video-player") .style("border: 2px solid #ccc; border-radius: 8px;"); // Video with event handlers Video interactive = new Video() .src("tutorial.mp4") .controls(true) .onplay("trackVideoPlay()") .onended("showNextVideo()");

The following convenience methods are provided for constructing instances of this bean:

See Also:
  • Constructor Details

    • Video

      public Video()
      Creates an empty Video element.
    • Video

      public Video(Object src)
      Creates a Video element with the specified src(Object) attribute.
      Parameters:
      src - The src(Object) attribute. Can be null, in which case the attribute is stored with a null value (not removed).
  • Method Details

    • autoplay

      public Video autoplay(Object value)
      autoplay attribute.

      Hint that the media resource can be started automatically when the page is loaded.

      This attribute uses deminimized values:

      • false - Attribute is not added
      • true - Attribute is added as "autoplay"
      • Other values - Passed through as-is
      Parameters:
      value - The new value for this attribute. Typically a Boolean or String. Can be null to unset the attribute.
      Returns:
      This object.
    • controls

      public Video controls(Object value)
      controls attribute.

      Show user agent controls.

      This attribute uses deminimized values:

      • false - Attribute is not added
      • true - Attribute is added as "controls"
      • Other values - Passed through as-is
      Parameters:
      value - The new value for this attribute. Typically a Boolean or String. Can be null to unset the attribute.
      Returns:
      This object.
    • crossorigin

      public Video crossorigin(String value)
      crossorigin attribute.

      Specifies how the element handles cross-origin requests for CORS (Cross-Origin Resource Sharing).

      Possible values:

      • "anonymous" - Cross-origin requests are made without credentials
      • "use-credentials" - Cross-origin requests include credentials
      Parameters:
      value - How to handle cross-origin requests. Can be null to unset the attribute.
      Returns:
      This object.
    • height

      public Video height(Object value)
      height attribute.

      Vertical dimension.

      Parameters:
      value - The new value for this attribute. Typically a Number or String. Can be null to unset the attribute.
      Returns:
      This object.
    • loop

      public Video loop(Object value)
      loop attribute.

      Causes the media to automatically restart from the beginning when it reaches the end.

      Parameters:
      value - If true, the media will loop continuously. Can be null to unset the attribute.
      Returns:
      This object.
    • mediagroup

      public Video mediagroup(String value)
      mediagroup attribute.

      Groups multiple media elements together so they can be controlled as a single unit. All media elements with the same mediagroup value will share the same MediaController, allowing synchronized playback.

      This is useful for creating synchronized audio/video presentations or multiple camera angles.

      Parameters:
      value - The name of the media group to join. Can be null to unset the attribute.
      Returns:
      This object.
    • muted

      public Video muted(Object value)
      muted attribute.

      Mutes the audio output by default. Useful for autoplay videos where audio should be disabled initially.

      Parameters:
      value - If true, the media will be muted by default. Can be null to unset the attribute.
      Returns:
      This object.
    • poster

      public Video poster(String value)
      poster attribute.

      Specifies an image to display as a placeholder before the video starts playing. This image is shown while the video is loading or before the user clicks play.

      The poster image should be representative of the video content and help users understand what the video contains.

      Parameters:
      value - The URL of the poster image to display before video playback. Can be null to unset the attribute.
      Returns:
      This object.
    • preload

      public Video preload(String value)
      preload attribute.

      Specifies how the browser should load the media resource.

      Possible values:

      • "none" - Do not preload the media
      • "metadata" - Preload only metadata (duration, dimensions, etc.)
      • "auto" - Preload the entire media file (default)
      Parameters:
      value - How much of the media to preload. Can be null to unset the attribute.
      Returns:
      This object.
    • src

      public Video src(Object value)
      src attribute.

      Address of the resource.

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      URIs defined by UriResolver can be used for values.

      Parameters:
      value - The new value for this attribute. Typically a URL or String. Can be null, in which case the attribute is stored with a null value (not removed).
      Returns:
      This object.
    • width

      public Video width(Object value)
      width attribute.

      Horizontal dimension.

      Parameters:
      value - The new value for this attribute. Typically a Number or String. Can be null to unset the attribute.
      Returns:
      This object.