Class WAbstractMedia
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.WWidget
-
- eu.webtoolkit.jwt.WWebWidget
-
- eu.webtoolkit.jwt.WInteractWidget
-
- eu.webtoolkit.jwt.WAbstractMedia
-
public abstract class WAbstractMedia extends WInteractWidget
Abstract baseclass for native media elements.This class is an abstract base class for HTML5 media elements (<audio>, <video>).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
-
Field Summary
-
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_, noDefault
-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WAbstractMedia()Consctructor for a media widget.WAbstractMedia(WContainerWidget parentContainer)Consctructor for a media widget.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSource(WLink link)Add a media source.voidaddSource(WLink link, java.lang.String type)Add a media source.voidaddSource(WLink link, java.lang.String type, java.lang.String media)Add a media source.voidclearSources()Removes all source elements.protected DomElementcreateDomElement(WApplication app)Create DOM element for widget.protected voidenableAjax()Progresses to an Ajax-enabled widget.EventSignalended()Event signal emitted when the playback stopped because the end of the media was reached.protected voidgetDomChanges(java.util.List<DomElement> result, WApplication app)Get DOM changes for this widget.java.lang.StringgetJsMediaRef()Returns the JavaScript reference to the media object, or null.java.util.EnumSet<PlayerOption>getOptions()Retrieve the configured options.MediaPreloadModegetPreloadMode()Retrieve the preload mode.MediaReadyStategetReadyState()Returns the media's readyState.booleanisPlaying()Returns whether the media is playing.protected voiditerateChildren(HandleWidgetMethod method)voidpause()Invokepause()on the media element.voidplay()Invokeplay()on the media element.EventSignalplaybackPaused()Event signal emitted when the playback has paused.EventSignalplaybackStarted()Event signal emitted when playback has begun.voidremove()Destructor.voidsetAlternativeContent(WWidget alternative)Content to be shown when media cannot be played.protected voidsetFormData(WObject.FormData formData)voidsetOptions(PlayerOption flag, PlayerOption... flags)Set the media element options.voidsetOptions(java.util.EnumSet<PlayerOption> flags)Set the media element options.voidsetPreloadMode(MediaPreloadMode mode)Set the preload mode.EventSignaltimeUpdated()Event signal emitted when the current playback position has changed.EventSignalvolumeChanged()Event signal emitted when the playback volume has changed.-
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, propagateSetEnabled, render, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
-
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, hideToolTip, isCanReceiveFocus, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, refresh, removeScript, removeStyleClass, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
-
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
-
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName
-
-
-
-
Constructor Detail
-
WAbstractMedia
public WAbstractMedia(WContainerWidget parentContainer)
Consctructor for a media widget.A freshly constructed media widget has no options set, no media sources, and has preload mode set to PreloadAuto.
-
WAbstractMedia
public WAbstractMedia()
Consctructor for a media widget.
-
-
Method Detail
-
remove
public void remove()
Description copied from class:WWidgetDestructor.Deletes a widget and all contained contents.
- Overrides:
removein classWInteractWidget- See Also:
WWidget.removeWidget(WWidget widget)
-
setOptions
public void setOptions(java.util.EnumSet<PlayerOption> flags)
Set the media element options.
-
setOptions
public final void setOptions(PlayerOption flag, PlayerOption... flags)
Set the media element options.
-
getOptions
public java.util.EnumSet<PlayerOption> getOptions()
Retrieve the configured options.
-
setPreloadMode
public void setPreloadMode(MediaPreloadMode mode)
Set the preload mode.
-
getPreloadMode
public MediaPreloadMode getPreloadMode()
Retrieve the preload mode.
-
clearSources
public void clearSources()
Removes all source elements.This method can be used to remove all media sources. Afterward, you may add new media sources with calls to
addSource().Use this to reuse a
WAbstractMediainstantiation to play something else.
-
addSource
public void addSource(WLink link, java.lang.String type, java.lang.String media)
Add a media source.This method specifies a media source (which may be a URL or dynamic resource). You may add as many media sources as you want. The browser will select the appropriate media stream to display to the user.
This method specifies a media source using the URL, the mime type, and the media attribute. HTML allows for empty type and media attributes.
-
addSource
public final void addSource(WLink link)
Add a media source.Calls
addSource(link, "", "")
-
addSource
public final void addSource(WLink link, java.lang.String type)
Add a media source.
-
setAlternativeContent
public void setAlternativeContent(WWidget alternative)
Content to be shown when media cannot be played.As not all browsers are HTML5 compliant, it is a good idea to provide fallback options when the media cannot be displayed. If the media can be played by the browser, the alternative content will be suppressed.
The two reasons to display the alternative content are (1) the media tag is not supported, or (2) the media tag is supported, but none of the media sources are supported by the browser. In the first case, fall-back is automatic and does not rely on JavaScript in the browser; in the latter case, JavaScript is required to make the fallback work.
The alternative content can be any widget: you can set it to an alternative media player (QuickTime, Flash, ...), show a Flash movie, an animated gif, a text, a poster image, ...
-
play
public void play()
Invokeplay()on the media element.JavaScript must be available for this function to work.
-
pause
public void pause()
Invokepause()on the media element.JavaScript must be available for this function to work.
-
isPlaying
public boolean isPlaying()
Returns whether the media is playing.
-
getReadyState
public MediaReadyState getReadyState()
Returns the media's readyState.
-
playbackStarted
public EventSignal playbackStarted()
Event signal emitted when playback has begun.This event fires when play was invoked, or when the media element starts playing because the Autoplay option was provided.
Note: When JavaScript is disabled, the signal will never fire.
-
playbackPaused
public EventSignal playbackPaused()
Event signal emitted when the playback has paused.Note: When JavaScript is disabled, the signal will never fire.
-
ended
public EventSignal ended()
Event signal emitted when the playback stopped because the end of the media was reached.Note: When JavaScript is disabled, the signal will never fire.
-
timeUpdated
public EventSignal timeUpdated()
Event signal emitted when the current playback position has changed.This event is fired when the playback position has changed, both when the media is in a normal playing mode, but also when it has changed discontinuously because of another reason.
Note: When JavaScript is disabled, the signal will never fire.
-
volumeChanged
public EventSignal volumeChanged()
Event signal emitted when the playback volume has changed.Note: When JavaScript is disabled, the signal will never fire.
-
getJsMediaRef
public java.lang.String getJsMediaRef()
Returns the JavaScript reference to the media object, or null.It is possible, for browser compatibility reasons, that
WWidget.getJsRef()is not the media element.getJsMediaRef()is guaranteed to be an expression that evaluates to the media object. This expression may yield null, if the video object is not rendered at all (e.g. on older versions of Internet Explorer).
-
getDomChanges
protected void getDomChanges(java.util.List<DomElement> result, WApplication app)
Description copied from class:WWebWidgetGet DOM changes for this widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
getDomChangesin classWWebWidget
-
createDomElement
protected DomElement createDomElement(WApplication app)
Description copied from class:WWebWidgetCreate DOM element for widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
createDomElementin classWWebWidget
-
iterateChildren
protected void iterateChildren(HandleWidgetMethod method)
- Overrides:
iterateChildrenin classWWebWidget
-
setFormData
protected void setFormData(WObject.FormData formData)
- Overrides:
setFormDatain classWObject
-
enableAjax
protected void enableAjax()
Description copied from class:WWidgetProgresses to an Ajax-enabled widget.This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.
You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.
- Overrides:
enableAjaxin classWWebWidget- See Also:
WApplication.enableAjax()
-
-