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
Modifier and TypeClassDescriptionstatic enum
Data pre-load modes for HTML<audio>
elements.static class
Represents a<source>
sub-element in an<audio>
element.Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
HasText.WhiteSpace
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an audio source with the specified URL and MIME type.void
Add an audio source and attempt to automatically infer its MIME type based on the URI path suffix.void
Add an audio source with the specified URL and MIME type.protected String
inferMimeType
(String filename) Attempt to automatically infer an audio MIME type based on a file name.void
play()
Start playing the audio.void
Remove all audio sources.void
setAltText
(String text) Configure alternate text.protected void
setAttribute
(String name, Object value) void
setLoop
(boolean loop) Configure whether the audio should loop.void
setMuted
(boolean muted) Configure whether the audio be muted.void
setPreload
(Audio.PreloadMode preload) Configure what data to pre-load.void
setShowControls
(boolean controls) Configure whether audio controls should be visible.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitle
Methods 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, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAll
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
Methods 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, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods 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
- ifuri
is 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
- iffilename
is null
-