eu.webtoolkit.jwt
Class WVideo

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WWebWidget
              extended by eu.webtoolkit.jwt.WInteractWidget
                  extended by eu.webtoolkit.jwt.WAbstractMedia
                      extended by eu.webtoolkit.jwt.WVideo

public class WVideo
extends WAbstractMedia

A video-playing widget.

This is a low-level widget, mapping directly onto a <video> element available in HTML5 compliant browsers.

In almost every situation you should use the WMediaPlayer widget instead, which has fallback and flexible user-interface options.

Usage of the video element consists of adding one or more video sources and setting some options. Since not every browser supports HTML5 video, the class provides a mechanism to display alternative content in browsers that cannot play the video.

There are two reasons why the a browser may use the alternative content: either because the browser does not support the HTML5 video tag (alternative content is displayed even when JavaScript is not available), or because none of the specified sources contain a video format that is understood by the browser (requires JavaScript to display the alternative content).

The WAbstractMedia#addSource() and WAbstractMedia#setAlternativeContent() may not be called after the widget is rendered.

See Also:
WMediaPlayer

Nested Class Summary
 
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WAbstractMedia
WAbstractMedia.Options, WAbstractMedia.PreloadMode, WAbstractMedia.ReadyState
 
Constructor Summary
WVideo()
          Creates a video widget.
WVideo(WContainerWidget parent)
          Creates a video widget.
 
Method Summary
 java.lang.String getJsVideoRef()
          Returns the JavaScript reference to the video object, or null.
 void resize(WLength width, WLength height)
          Resizes the widget.
 void setPoster(java.lang.String url)
          Set the poster image.
 
Methods inherited from class eu.webtoolkit.jwt.WAbstractMedia
addSource, addSource, addSource, clearSources, ended, getJsMediaRef, getOptions, getPreloadMode, getReadyState, isPlaying, pause, play, playbackPaused, playbackStarted, remove, setAlternativeContent, setOptions, setOptions, setPreloadMode, timeUpdated, volumeChanged
 
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, propagateSetEnabled, setDraggable, setDraggable, setDraggable, setDraggable, touchEnded, touchMoved, touchStarted
 
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, callJavaScriptMember, childrenChanged, doJavaScript, domCanBeSaved, enableAjax, escapeText, escapeText, escapeText, escapeText, find, getAttributeValue, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isVisible, jsStringLiteral, jsStringLiteral, refresh, removeScript, removeStyleClass, render, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHidden, setHiddenKeepsGeometry, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setTabIndex, setToolTip, setVerticalAlignment, updateSignalConnection
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, 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
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WVideo

public WVideo(WContainerWidget parent)
Creates a video widget.

The constructor sets the 'controls' option, which causes the browser to display a bar with play/pauze/volume/... controls.

A freshly constructed video widget has no poster image, no media sources, has preload mode set to PreloadAuto, and only the Controls flag is set.


WVideo

public WVideo()
Creates a video widget.

Calls this((WContainerWidget)null)

Method Detail

setPoster

public void setPoster(java.lang.String url)
Set the poster image.

On browsers that support it, the poster image is displayed before the video is playing. Some browsers display the first frame of the video stream once the video stream is loaded; it is therefore a good idea to include the poster image as first frame in the video feed too.


getJsVideoRef

public java.lang.String getJsVideoRef()
Returns the JavaScript reference to the video object, or null.

It is possible, for compatibility reasons, that WWidget#getJsRef() is not the video element. getJsVideoRef() is guaranteed to be an expression that evaluates to the video object. This expression may yield null, if the video object is not rendered at all (e.g. on older versions of Internet Explorer).


resize

public void resize(WLength width,
                   WLength height)
Description copied from class: WWidget
Resizes the widget.

Specify a new size for this widget, by specifying width and height. By default a widget has automatic width and height, see WLength#isAuto().

This applies to CSS-based layout, and only block widgets can be given a size reliably.

When inserted in a layout manager, the widget may be informed about its current size using setLayoutSizeAware(). If you have defined a "wtResize()" JavaScript method for the widget, then this method will also be called. operation.

Overrides:
resize in class WWebWidget
See Also:
WWidget.getWidth(), WWidget.getHeight()