Class Audio
The audio element embeds sound content in documents. It can contain audio streams, audio files, or other audio sources. The browser will choose the most appropriate source based on format support and user preferences.
Examples:
The following convenience methods are provided for constructing instances of this bean:
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionautoplay attribute.controls attribute.crossorigin(String value) crossorigin attribute.loop attribute.mediagroup(String value) mediagroup attribute.muted attribute.preload attribute.src attribute.Methods inherited from class org.apache.juneau.bean.html5.HtmlElementMixed
child, children, getChild, getChild, getChild, getChildren, setChildrenMethods inherited from class org.apache.juneau.bean.html5.HtmlElement
accesskey, attr, attrUri, class_, contenteditable, deminimize, dir, getAttr, getAttr, getAttrs, hidden, id, lang, onabort, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, oncuechange, ondblclick, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting, self, setAttrs, spellcheck, style, tabindex, title, toString, translate
-
Constructor Details
-
Audio
public Audio()Creates an emptyAudioelement. -
Audio
Creates anAudioelement with the specifiedsrc(Object)attribute.- Parameters:
src- Thesrc(Object)attribute. Can benull , in which case the attribute is stored with anull value (not removed).
-
-
Method Details
-
autoplay
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 addedtrue - Attribute is added as"autoplay" - Other values - Passed through as-is
-
controls
controls attribute.Show user agent controls.
This attribute uses deminimized values:
false - Attribute is not addedtrue - Attribute is added as"controls" - Other values - Passed through as-is
-
crossorigin
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 benull to unset the attribute.- Returns:
- This object.
-
loop
loop attribute.Causes the media to automatically restart from the beginning when it reaches the end.
- Parameters:
value- Iftrue , the media will loop continuously. Can benull to unset the attribute.- Returns:
- This object.
-
mediagroup
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 audio tracks.
- Parameters:
value- The name of the media group to join. Can benull to unset the attribute.- Returns:
- This object.
-
muted
muted attribute.Mutes the audio output by default. Useful for autoplay videos where audio should be disabled initially.
- Parameters:
value- Iftrue , the media will be muted by default. Can benull to unset the attribute.- Returns:
- This object.
-
preload
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 benull to unset the attribute.- Returns:
- This object.
-
src
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
UriResolvercan be used for values.
-