Class AbstractMedia
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractMedia
-
- All Implemented Interfaces:
ContextClickEvent.ContextClickNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,Connector
,Component
,Serializable
public abstract class AbstractMedia extends AbstractComponent
Abstract base class for the HTML5 media components.- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description AbstractMedia()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSource(Resource source)
Adds an alternative media file to the sources list.String
getAltText()
protected Collection<String>
getCustomAttributes()
Returns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
andAbstractComponent.writeDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
methods.PreloadMode
getPreload()
List<Resource>
getSources()
protected AbstractMediaState
getState()
Returns the shared state bean with information to be sent from the server to the client.protected AbstractMediaState
getState(boolean markAsDirty)
Returns the shared state for this connector.boolean
handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path)
Handle a request directed to this connector.boolean
isAutoplay()
boolean
isHtmlContentAllowed()
boolean
isLoop()
boolean
isMuted()
boolean
isShowControls()
void
pause()
Pauses the media.void
play()
Starts playback of the media.void
readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Reads the component state from the given design.void
setAltText(String altText)
Sets the alternative text to be displayed if the browser does not support HTML5.void
setAutoplay(boolean autoplay)
Sets whether the media is to automatically start playback when enough data has been loaded.void
setHtmlContentAllowed(boolean htmlContentAllowed)
Set whether the alternative text (setAltText(String)
) is rendered as HTML or not.void
setLoop(boolean loop)
Enables or disables looping.void
setMuted(boolean muted)
Set whether to mute the audio or not.void
setPreload(PreloadMode preload)
Sets the preload attribute that is intended to provide a hint to the browser how the media should be preloaded.void
setShowControls(boolean showControls)
Sets whether or not the browser should show native media controls.void
setSource(Resource source)
Sets a single media file as the source of the media component.void
setSources(Resource... sources)
Set multiple sources at once.void
writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Writes the component state to the given design.-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, isAttached, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
-
-
-
Method Detail
-
getState
protected AbstractMediaState getState()
Description copied from class:AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().- Overrides:
getState
in classAbstractComponent
- Returns:
- updated component shared state
-
getState
protected AbstractMediaState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnector
Returns the shared state for this connector.- Overrides:
getState
in classAbstractComponent
- Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwise- Returns:
- The shared state for this connector. Never null.
- See Also:
AbstractClientConnector.getState()
-
setSource
public void setSource(Resource source)
Sets a single media file as the source of the media component.- Parameters:
source
-
-
addSource
public void addSource(Resource source)
Adds an alternative media file to the sources list. Which of the sources is used is selected by the browser depending on which file formats it supports. See wikipedia for a table of formats supported by different browsers.- Parameters:
source
-
-
handleConnectorRequest
public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException
Description copied from interface:ClientConnector
Handle a request directed to this connector. This can be used by connectors to dynamically generate a response and it is also used internally when servingConnectorResource
s.Requests to
/APP/connector/[ui id]/[connector id]/
are routed to this method with the remaining part of the requested path available in the path parameter.NOTE that the session is not locked when this method is called. It is the responsibility of the connector to ensure that the session is locked while handling state or other session related data. For best performance the session should be unlocked before writing a large response to the client.
- Specified by:
handleConnectorRequest
in interfaceClientConnector
- Overrides:
handleConnectorRequest
in classAbstractClientConnector
- Parameters:
request
- the request that should be handledresponse
- the response object to which the response should be writtenpath
- the requested relative path- Returns:
true
if the request has been handled,false
if no response has been written.- Throws:
IOException
- if there is a problem generating a response.
-
setSources
public void setSources(Resource... sources)
Set multiple sources at once. Which of the sources is used is selected by the browser depending on which file formats it supports. See wikipedia for a table of formats supported by different browsers.- Parameters:
sources
-
-
setShowControls
public void setShowControls(boolean showControls)
Sets whether or not the browser should show native media controls.- Parameters:
showControls
-
-
isShowControls
public boolean isShowControls()
- Returns:
- true if the browser is to show native media controls.
-
setAltText
public void setAltText(String altText)
Sets the alternative text to be displayed if the browser does not support HTML5. This text is rendered as HTML ifsetHtmlContentAllowed(boolean)
is set to true. With HTML rendering, this method can also be used to implement fallback to a flash-based player, see the Mozilla Developer Network for details.- Parameters:
altText
-
-
getAltText
public String getAltText()
- Returns:
- The text/html that is displayed when a browser doesn't support HTML5.
-
setPreload
public void setPreload(PreloadMode preload)
Sets the preload attribute that is intended to provide a hint to the browser how the media should be preloaded. Valid values are 'none', 'metadata', 'preload', see the Mozilla Developer Network for details.- Parameters:
preload
- preload mode- Since:
- 7.7.11
-
getPreload
public PreloadMode getPreload()
- Returns:
- the configured media preload value
- Since:
- 7.7.11
-
setLoop
public void setLoop(boolean loop)
Enables or disables looping.- Parameters:
loop
- if true, enable looping- Since:
- 7.7.11
-
isLoop
public boolean isLoop()
- Returns:
- true if looping is enabled
- Since:
- 7.7.11
-
setHtmlContentAllowed
public void setHtmlContentAllowed(boolean htmlContentAllowed)
Set whether the alternative text (setAltText(String)
) is rendered as HTML or not.- Parameters:
htmlContentAllowed
-
-
isHtmlContentAllowed
public boolean isHtmlContentAllowed()
- Returns:
- true if the alternative text (
setAltText(String)
) is to be rendered as HTML.
-
setAutoplay
public void setAutoplay(boolean autoplay)
Sets whether the media is to automatically start playback when enough data has been loaded.- Parameters:
autoplay
-
-
isAutoplay
public boolean isAutoplay()
- Returns:
- true if the media is set to automatically start playback.
-
setMuted
public void setMuted(boolean muted)
Set whether to mute the audio or not.- Parameters:
muted
-
-
isMuted
public boolean isMuted()
- Returns:
- true if the audio is muted.
-
pause
public void pause()
Pauses the media.
-
play
public void play()
Starts playback of the media.
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Description copied from interface:Component
Writes the component state to the given design.The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
- Specified by:
writeDesign
in interfaceComponent
- Overrides:
writeDesign
in classAbstractComponent
- Parameters:
design
- The element to write the component state to. Any previous attributes or child nodes are not cleared.designContext
- The DesignContext instance used for writing the design
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Description copied from interface:Component
Reads the component state from the given design.The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
- Specified by:
readDesign
in interfaceComponent
- Overrides:
readDesign
in classAbstractComponent
- Parameters:
design
- The element to obtain the state fromdesignContext
- The DesignContext instance used for parsing the design
-
getCustomAttributes
protected Collection<String> getCustomAttributes()
Description copied from class:AbstractComponent
Returns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
andAbstractComponent.writeDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
methods. Typically these are handled in a custom way in the overridden versions of the above methods- Overrides:
getCustomAttributes
in classAbstractComponent
- Returns:
- the collection of attributes that are not handled by the basic implementation
-
-