com.vaadin.ui.


Class AbstractMedia

java.lang.Object
  com.vaadin.ui.AbstractComponent
      com.vaadin.ui.AbstractMedia

All Implemented Interfaces:

MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Serializable, EventListener

Direct Known Subclasses:

Audio, Video

public 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 class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Field Summary
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
AbstractMedia()
           
 
Method Summary
 void addSource(Resource source)
          Adds an alternative media file to the sources list.
 String getAltText()
           
 List<Resource> getSources()
           
 boolean isAutoplay()
           
 boolean isHtmlContentAllowed()
           
 boolean isMuted()
           
 boolean isShowControls()
           
 void paintContent(PaintTarget target)
          Paints any needed component-specific things to the given UIDL stream.
 void pause()
          Pauses the media.
 void play()
          Starts playback of the media.
 void setAltText(String text)
          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 setMuted(boolean muted)
          Set whether to mute the audio or not.
 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.
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addListener, addStyleName, attach, changeVariables, childRequestedRepaint, detach, fireComponentErrorEvent, fireComponentEvent, fireEvent, focus, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, hasListeners, isEnabled, isImmediate, isReadOnly, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeight, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth, setWidth, setWidthUnits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMedia

public AbstractMedia()
Method Detail

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 -

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 -

getSources

public List<Resource> getSources()

Returns:
The sources pointed to in this media.

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 text)

Sets the alternative text to be displayed if the browser does not support HTML5. This text is rendered as HTML if setHtmlContentAllowed(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:
text -

getAltText

public String getAltText()

Returns:
The text/html that is displayed when a browser doesn't support HTML5.

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.

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException

Description copied from class: AbstractComponent

Paints any needed component-specific things to the given UIDL stream. The more general AbstractComponent.paint(PaintTarget) method handles all general attributes common to all components, and it calls this method to paint any component-specific attributes to the UIDL stream.

Overrides:
paintContent in class AbstractComponent

Parameters:
target - the target UIDL stream where the component should paint itself to
Throws:
PaintException - if the paint operation failed.