Class Audio
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.HtmlContainer
org.dellroad.stuff.vaadin24.audio.Audio
- All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasComponents, HasComponentsOfType<Component>, HasElement, HasEnabled, HasSize, HasStyle, HasText, Serializable
Represents an HTML
<audio> tag.
By default this class enables display of the audio controls.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumData pre-load modes for HTML<audio>elements.static classRepresents a<source>sub-element in an<audio>element.Nested classes/interfaces inherited from interface HasText
HasText.WhiteSpace -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an audio source with the specified URL and MIME type.voidAdd an audio source and attempt to automatically infer its MIME type based on the URI path suffix.voidAdd an audio source with the specified URL and MIME type.protected StringinferMimeType(String filename) Attempt to automatically infer an audio MIME type based on a file name.voidplay()Start playing the audio.voidRemove all audio sources.voidsetAltText(String text) Configure alternate text.protected voidsetAttribute(String name, Object value) voidsetLoop(boolean loop) Configure whether the audio should loop.voidsetMuted(boolean muted) Configure whether the audio be muted.voidsetPreload(Audio.PreloadMode preload) Configure what data to pre-load.voidsetShowControls(boolean controls) Configure whether audio controls should be visible.Methods inherited from class HtmlComponent
getTitle, setTitleMethods inherited from class Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisibleMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AttachNotifier
addAttachListenerMethods inherited from interface DetachNotifier
addDetachListenerMethods inherited from interface HasComponents
addMethods inherited from interface HasComponentsOfType
add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replaceMethods inherited from interface HasElement
getElementMethods inherited from interface HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface HasText
bindText, getText, getWhiteSpace, setText, setWhiteSpace
-
Constructor Details
-
Audio
public Audio()Constructor.
-
-
Method Details
-
setAltText
Configure alternate text.- Parameters:
text- alternate text or null for none
-
addSource
Add an audio source and attempt to automatically infer its MIME type based on the URI path suffix.- Parameters:
uri- audio source- Throws:
IllegalArgumentException- ifuriis nullIllegalArgumentException- ifuri's MIME type cannot be inferred
-
addSource
Add an audio source with the specified URL and MIME type.- Parameters:
uri- audio sourcemimeType- audio MIME type- Throws:
IllegalArgumentException- if either parameter is null
-
addSource
Add an audio source with the specified URL and MIME type.- Parameters:
uri- audio sourcemimeType- audio MIME type- Throws:
IllegalArgumentException- if either parameter is null
-
removeSources
public void removeSources()Remove all audio sources. -
setLoop
public void setLoop(boolean loop) Configure whether the audio should loop.- Parameters:
loop- true to loop, false to play once
-
setMuted
public void setMuted(boolean muted) Configure whether the audio be muted.- Parameters:
muted- true for muted, false for unmuted
-
setShowControls
public void setShowControls(boolean controls) Configure whether audio controls should be visible.- Parameters:
controls- true for visible audio controls, otherwise false
-
setPreload
Configure what data to pre-load.- Parameters:
preload- data pre-load setting, or null to remove this option
-
play
public void play()Start playing the audio. -
setAttribute
-
inferMimeType
Attempt to automatically infer an audio MIME type based on a file name.- Parameters:
filename- audio file name- Throws:
IllegalArgumentException- iffilename's MIME type cannot be inferredIllegalArgumentException- iffilenameis null
-