Class WVideo
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WVideo
-
- All Implemented Interfaces:
AjaxTarget
,Disableable
,SubordinateTarget
,Targetable
,WComponent
,WebComponent
,Serializable
public class WVideo extends AbstractWComponent implements Targetable, AjaxTarget, Disableable, SubordinateTarget
WVideo is used to display video content on the client.- Since:
- 1.0.0
- Author:
- Yiannis Paschalidis
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WVideo.Controls
Deprecated.replaced with renderControls accessorsisRenderControls()
andsetRenderControls(boolean)
static class
WVideo.Preload
This is used to indicate whether pre-loading of content should occur before the clip is played.static class
WVideo.VideoModel
Holds the extrinsic state information of a WVideo.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WVideo()
Creates a WVideo with no video clips.WVideo(Video video)
Creates a WVideo with the given video clip.WVideo(Video[] video)
Creates a WVideo with the given video clip in multiple formats.WVideo(String resource)
Creates a WVideo with the given static content.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
getAltText()
Deprecated.as not supported by HTML specString
getCacheKey()
protected WVideo.VideoModel
getComponentModel()
Returns the effective component model for this component.WVideo.Controls
getControls()
Deprecated.int
getHeight()
String
getMediaGroup()
protected WVideo.VideoModel
getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified.Image
getPoster()
Retrieves the default poster image.String
getPosterUrl()
Creates a dynamic URL that the poster can be loaded from.WVideo.Preload
getPreload()
Indicates how pre-loading of content should occur before the clip is played.String
getTargetId()
Returns the id to use to target this component.Track[]
getTracks()
Retrieves additional tracks associated with the video.String[]
getTrackUrls()
Creates dynamic URLs that the video clips can be loaded from.Video[]
getVideo()
Retrieves the video clips associated with this WVideo.String[]
getVideoUrls()
Creates dynamic URLs that the video clips can be loaded from.int
getWidth()
void
handleRequest(Request request)
When an video element is rendered to the client, the browser will make a second request to get the video content.boolean
isAutoplay()
boolean
isDisabled()
Deprecated.as not supported by HTML videoboolean
isLoop()
Indicates whether the video clip playback should loop.boolean
isMuted()
Indicates whether the video's audio should initially be muted.boolean
isRenderControls()
boolean
isVisible()
Override isVisible to also return false if there are no video clips to play.protected WVideo.VideoModel
newComponentModel()
Creates a new component model appropriate for this component.void
setAltText(String altText)
Deprecated.as not supported by HTML specvoid
setAutoplay(boolean autoplay)
Sets whether the clip should play automatically.void
setCacheKey(String cacheKey)
void
setControls(WVideo.Controls controls)
Deprecated.void
setDisabled(boolean disabled)
Deprecated.as not supported by HTML videovoid
setHeight(int height)
Sets the height of the video playback region on the client.void
setLoop(boolean loop)
Sets whether the video clip playback should loop or stop at the end.void
setMediaGroup(String mediaGroup)
Sets the media group.void
setMuted(boolean muted)
Sets whether the video's audio should initially be muted.void
setPoster(Image poster)
Sets the default poster image.void
setPreload(WVideo.Preload preload)
Sets how pre-loading of content should occur before the clip is played.void
setRenderControls(boolean renderControls)
Sets whether the browser should display default controls.void
setTracks(Track[] tracks)
Sets the tracks for the video.void
setVideo(Video video)
Sets the video clip.void
setVideo(Video[] video)
Sets the video clip in multiple formats.void
setWidth(int width)
Sets the width of the video playback region on the client.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, toString, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Constructor Detail
-
WVideo
public WVideo()
Creates a WVideo with no video clips. Video clips must be added later by calling one of the setVideo(...) methods.
-
WVideo
public WVideo(Video video)
Creates a WVideo with the given video clip.- Parameters:
video
- the video clip.
-
WVideo
public WVideo(String resource)
Creates a WVideo with the given static content. This is provided as a convenience method for when the video file is included as static content in the class path rather than in the web application's resources.
The mime type for the video clip is looked up from the "mimeType.*" mapping configuration parameters using the resource's file extension.
- Parameters:
resource
- the resource path to the video file.
-
WVideo
public WVideo(Video[] video)
Creates a WVideo with the given video clip in multiple formats. The client will try to load the first video clip, and if it fails or isn't supported, it will move on to the next video clip. Only the first clip which can be played on the client will be used.- Parameters:
video
- multiple formats for the same the video clip.
-
-
Method Detail
-
setVideo
public void setVideo(Video video)
Sets the video clip.- Parameters:
video
- the video clip.
-
setVideo
public void setVideo(Video[] video)
Sets the video clip in multiple formats. The client will try to load the first video clip, and if it fails or isn't supported, it will move on to the next video clip. Only the first clip which can be played on the client will be used.- Parameters:
video
- multiple formats for the same the video clip.
-
getVideo
public Video[] getVideo()
Retrieves the video clips associated with this WVideo.- Returns:
- the video clips, may be null.
-
isDisabled
@Deprecated public boolean isDisabled()
Deprecated.as not supported by HTML videoIndicates whether the video component is disabled.- Specified by:
isDisabled
in interfaceDisableable
- Returns:
- true if the component is disabled, otherwise false.
-
setDisabled
@Deprecated public void setDisabled(boolean disabled)
Deprecated.as not supported by HTML videoSets whether the video component is disabled.- Specified by:
setDisabled
in interfaceDisableable
- Parameters:
disabled
- if true, the component is disabled. If false, it is enabled.
-
isAutoplay
public boolean isAutoplay()
- Returns:
- true if the clip should start playing automatically, false for a manual start.
-
setAutoplay
public void setAutoplay(boolean autoplay)
Sets whether the clip should play automatically.- Parameters:
autoplay
- true to start playing automatically, false for a manual start.
-
getMediaGroup
public String getMediaGroup()
- Returns:
- the media group name.
-
setMediaGroup
public void setMediaGroup(String mediaGroup)
Sets the media group.- Parameters:
mediaGroup
- The media group name.
-
isLoop
public boolean isLoop()
Indicates whether the video clip playback should loop.- Returns:
- true to loop, false to stop at the end.
-
setLoop
public void setLoop(boolean loop)
Sets whether the video clip playback should loop or stop at the end.- Parameters:
loop
- true to loop, false to stop at the end.
-
isMuted
public boolean isMuted()
Indicates whether the video's audio should initially be muted.- Returns:
- true if muted, false otherwise.
-
setMuted
public void setMuted(boolean muted)
Sets whether the video's audio should initially be muted.- Parameters:
muted
- true to mute the audio, false to play normally.
-
getControls
@Deprecated public WVideo.Controls getControls()
Deprecated.Indicates which playback controls (e.g. stop/start/pause) to display on the video component.- Returns:
- the playback controls to display.
-
isRenderControls
public boolean isRenderControls()
- Returns:
- true is the browser should render the default video controls
-
setControls
@Deprecated public void setControls(WVideo.Controls controls)
Deprecated.Sets which playback controls (e.g. stop/start/pause) to display on the video component. The values ofWVideo.Controls.NONE
andWVideo.Controls.ALL
take precedence over all other values. Passing a null or empty set of controls will cause the client's default set of controls to be used.- Parameters:
controls
- the playback controls to display.
-
setRenderControls
public void setRenderControls(boolean renderControls)
Sets whether the browser should display default controls. You almost always want this true.- Parameters:
renderControls
- if true then the default controls are shown by the browser
-
getPreload
public WVideo.Preload getPreload()
Indicates how pre-loading of content should occur before the clip is played.- Returns:
- the pre-loading mode.
-
setPreload
public void setPreload(WVideo.Preload preload)
Sets how pre-loading of content should occur before the clip is played.- Parameters:
preload
- the pre-loading mode.
-
getAltText
@Deprecated public String getAltText()
Deprecated.as not supported by HTML spec- Returns:
- alternative text to display when the video clip can not be played.
-
setAltText
@Deprecated public void setAltText(String altText)
Deprecated.as not supported by HTML specSets the alternative text to display when the video clip can not be played.- Parameters:
altText
- the text to set.
-
getWidth
public int getWidth()
- Returns:
- the width of the video playback region on the client, in pixels.
-
setWidth
public void setWidth(int width)
Sets the width of the video playback region on the client.- Parameters:
width
- the width of the video playback region, in pixels.
-
getHeight
public int getHeight()
- Returns:
- the height of the video playback region on the client, in pixels.
-
setHeight
public void setHeight(int height)
Sets the height of the video playback region on the client.- Parameters:
height
- the height of the video playback region, in pixels.
-
getPoster
public Image getPoster()
Retrieves the default poster image. The poster image is displayed by the client when the video is not playing.- Returns:
- the default poster image.
-
setPoster
public void setPoster(Image poster)
Sets the default poster image. The poster image is displayed by the client when the video is not playing.- Parameters:
poster
- the default poster image.
-
setTracks
public void setTracks(Track[] tracks)
Sets the tracks for the video. The tracks are used to provide additional information relating to the video, for example subtitles.- Parameters:
tracks
- additional tracks relating to the video.
-
getTracks
public Track[] getTracks()
Retrieves additional tracks associated with the video. The tracks provide additional information relating to the video, for example subtitles.- Returns:
- the video clips, may be null.
-
getVideoUrls
public String[] getVideoUrls()
Creates dynamic URLs that the video clips can be loaded from. In fact the URL points to the main application servlet, but includes a non-null for the parameter associated with this WComponent (ie, its label). The handleRequest method below detects this when the browser requests a file.- Returns:
- the urls to load the video files from, or null if there are no clips defined.
-
getTrackUrls
public String[] getTrackUrls()
Creates dynamic URLs that the video clips can be loaded from. In fact the URL points to the main application servlet, but includes a non-null for the parameter associated with this WComponent (ie, its label). The handleRequest method below detects this when the browser requests a file.- Returns:
- the urls to load the video files from, or null if there are no clips defined.
-
getPosterUrl
public String getPosterUrl()
Creates a dynamic URL that the poster can be loaded from. In fact the URL points to the main application servlet, but includes a non-null for the parameter associated with this WComponent (ie, its label). The handleRequest method below detects this when the browser requests a file.- Returns:
- the url to load the poster from, or null if there is no poster defined.
-
isVisible
public boolean isVisible()
Override isVisible to also return false if there are no video clips to play.- Specified by:
isVisible
in interfaceWComponent
- Overrides:
isVisible
in classAbstractWComponent
- Returns:
- true if this component is visible in the given context, otherwise false.
-
handleRequest
public void handleRequest(Request request)
When an video element is rendered to the client, the browser will make a second request to get the video content. The handleRequest method has been overridden to detect whether the request is the "content fetch" request by looking for the parameter that we encode in the content url.- Specified by:
handleRequest
in interfaceWComponent
- Overrides:
handleRequest
in classAbstractWComponent
- Parameters:
request
- the request being responded to.
-
getCacheKey
public String getCacheKey()
- Returns:
- the cacheKey
-
setCacheKey
public void setCacheKey(String cacheKey)
- Parameters:
cacheKey
- the cacheKey to set.
-
getTargetId
public String getTargetId()
Returns the id to use to target this component.- Specified by:
getTargetId
in interfaceTargetable
- Returns:
- this component's target id.
-
newComponentModel
protected WVideo.VideoModel newComponentModel()
Creates a new component model appropriate for this component.- Overrides:
newComponentModel
in classAbstractWComponent
- Returns:
- a new VideoModel.
-
getComponentModel
protected WVideo.VideoModel getComponentModel()
Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModel
in classAbstractWComponent
- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WVideo.VideoModel getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModel
in classAbstractWComponent
- Returns:
- the model for this component
-
-