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,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 com.vaadin.flow.component.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 com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
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 com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
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
-