Class Source


@Bean(typeName="source") public class Source extends HtmlElementVoid
DTO for an HTML <source> element.

The source element specifies multiple media resources for media elements like audio and video. It allows browsers to choose the most appropriate source based on format support, bandwidth, and other factors. The source element is used inside audio and video elements to provide fallback options for different media formats.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Video with multiple sources Video video = video() .controls(true) .children( source().src("movie.mp4").type("video/mp4"), source().src("movie.webm").type("video/webm"), source().src("movie.ogg").type("video/ogg") ); // Audio with multiple sources Audio audio = audio() .controls(true) .children( source().src("sound.mp3").type("audio/mpeg"), source().src("sound.ogg").type("audio/ogg"), source().src("sound.wav").type("audio/wav") ); // Picture with multiple sources Picture picture = picture( source().src("image.webp").type("image/webp"), source().src("image.jpg").type("image/jpeg") ); // Source with media query Source responsive = source() .src("large-image.jpg") .media("(min-width: 800px)") .type("image/jpeg");

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

See Also: