Class Video
- All Implemented Interfaces:
Serializable,Cloneable,Component,Scope,ComponentCtrl,MediaElement
Only works for browsers supporting HTML5 video tag
- Since:
- 8.6.0
- Author:
- charlesqiu
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA utility class to implementHtmlBasedComponent.getExtraCtrl().Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children, AbstractComponent.ForwardInfo, AbstractComponent.TargetInfo -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intRepresent the end statestatic final intRepresent the pause statestatic final intRepresent the play statestatic final intRepresent the stop stateFields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeChildAdded(Component child, Component insertBefore) Default: does nothing.Note: it won't fetch what is set thru bysetSrc(java.lang.String).Returns the crossorigin of this video tag, could be "anonymous", "use-credentials" or null.Returns the client control for this component.doubleReturns the video play speed.Returns the image source, if didn't set the image, return null.Returns "none" or "metadata" or "auto" or nullgetSrc()Returns the video source as List.doubleReturns the volume of video.booleanReturns whether to auto start playing the video.booleanReturn whether to clip video when the source size doesn't fit the tag size setting, for example: if video source is 1280 * 720, but the video tag isbooleanReturns whether to display the video controls.booleanReturns whether to turn whole page to be covered by translucent black except the Video, also called theater mode.booleanisEnded()Return whether the video is ended.booleanisLoop()Returns whether to play the video repeatedly.booleanisMuted()Returns whether the video is muted.booleanisPaused()Return whether the video is paused.booleanReturn whether the video is playing.booleanReturns the playsinline of this video tag.booleanReturn whether the video is stopped.voidpause()Pause the video at the client.voidplay()Play the video at the client.protected voidrenderProperties(ContentRenderer renderer) Renders the content of this component, excluding the enclosing tags and children.voidProcesses an AU request.voidsetAutoplay(boolean autoplay) Sets whether to auto start playing the video.voidsetClipToFit(boolean clipToFit) Set whether to clip video when the source size doesn't fit the tag size setting, for example: if video source is 1280 * 720, but the video tag isvoidsetContent(Video content) Calling this method implies setSrc(null).voidsetControls(boolean controls) Sets whether to display the video controls.voidsetCrossorigin(String crossorigin) Could be "anonymous" or "use-credentials", an invalid string and an empty string will be handled as the "anonymous".voidsetCurrentTime(double currentTime) Sets which part of video to play.voidsetDimBackground(boolean dimBackground) Sets whether to turn whole page to be covered by translucent black except Video, also called theater mode.voidsetLoop(boolean loop) Sets whether to play the video repeatedly.voidsetMuted(boolean muted) Sets whether to mute the video.voidsetPlaybackRate(double playbackRate) Sets the video play speed, type of value is in double, valid value is depending on browser.voidsetPlaying(boolean playing) voidsetPlaysinline(boolean playsinline) Sets the playsinline of this video tag.voidSets an image to be shown while the video is downloading, or until the user hits the play button.voidsetPreload(String preload) Sets whether and how the video should be loaded, which could be one of "none", "metadata", "auto".voidCalling this method implies setContent(null).voidsetSrcList(List<String> src) Sets the source list, be invoked by thesetSrc(String).voidsetVolume(double volume) Sets the volume of video.voidstop()Stop the video at the client.protected voidupdateByClient(String name, Object value) Called when the widget running at the client asks the server to update a value.Methods inherited from class org.zkoss.zul.impl.XulElement
clone, getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributesMethods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getStubonlyDescendants, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setStubonlyDescendants, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
Field Details
-
STOP
public static final int STOPRepresent the stop state- See Also:
-
PLAY
public static final int PLAYRepresent the play state- See Also:
-
PAUSE
public static final int PAUSERepresent the pause state- See Also:
-
END
public static final int ENDRepresent the end state- Since:
- 9.6.0
- See Also:
-
-
Constructor Details
-
Video
public Video() -
Video
-
-
Method Details
-
isAutoplay
public boolean isAutoplay()Returns whether to auto start playing the video.Default: false.
- Returns:
- true if video enable autoplay function.
-
setAutoplay
public void setAutoplay(boolean autoplay) Sets whether to auto start playing the video.- Parameters:
autoplay- whether to enable autoplay function.
-
isControls
public boolean isControls()Returns whether to display the video controls.Default: false.
- Returns:
- true if video display the controls.
-
setControls
public void setControls(boolean controls) Sets whether to display the video controls.- Parameters:
controls- whether to display the video controls.
-
isLoop
public boolean isLoop()Returns whether to play the video repeatedly.Default: false.
- Returns:
- true if video enable loop function.
-
setLoop
public void setLoop(boolean loop) Sets whether to play the video repeatedly.- Parameters:
loop- whether to enable loop function.
-
isDimBackground
public boolean isDimBackground()Returns whether to turn whole page to be covered by translucent black except the Video, also called theater mode. When theater mode is enabled, user can click anywhere on the page except the Video to disable theater mode.Default: false.
- Returns:
- true if theater mode is enabled.
-
setDimBackground
public void setDimBackground(boolean dimBackground) Sets whether to turn whole page to be covered by translucent black except Video, also called theater mode. When theater mode is enabled, user can click anywhere on the page except the Video to disable theater mode.- Parameters:
dimBackground- whether to enable theater mode.
-
getPreload
Returns "none" or "metadata" or "auto" or nullDefault: null.
- Returns:
- whether and how the video should be loaded.
-
setPreload
Sets whether and how the video should be loaded, which could be one of "none", "metadata", "auto". Refer to Preload Attribute Description for details.- Parameters:
preload- which could be one of "none", "metadata", "auto".
-
getPoster
Returns the image source, if didn't set the image, return null.Default: null.
- Returns:
- the image source.
-
setPoster
Sets an image to be shown while the video is downloading, or until the user hits the play button.- Parameters:
poster- the image source.
-
getSrc
Returns the video source as List.Default: [].
- Returns:
- the video source.
-
setSrc
Calling this method implies setContent(null). In other words, the last invocation of
setSrc(java.lang.String)overrides the previoussetContent(org.zkoss.video.Video), if any.- Parameters:
src- the video sources separated by ','.- See Also:
-
setSrcList
Sets the source list, be invoked by thesetSrc(String).- Parameters:
src- the source list.
-
getCrossorigin
Returns the crossorigin of this video tag, could be "anonymous", "use-credentials" or null.Default: null.
- Returns:
- the crossorigin of this video tag.
-
setCrossorigin
Could be "anonymous" or "use-credentials", an invalid string and an empty string will be handled as the "anonymous". Notice that this attribute refers to the corresponding attribute of the HTML5 specification. Hence, it would still be rendered to client-side as a DOM attribute even if the browser doesn’t support it.
- Parameters:
crossorigin- the crossorigin of this video tag.
-
isPlaysinline
public boolean isPlaysinline()Returns the playsinline of this video tag.Default: false.
- Returns:
- true if the video enable playsinline function.
-
setPlaysinline
public void setPlaysinline(boolean playsinline) Sets the playsinline of this video tag. Notice that this attribute refers to the corresponding attribute of the HTML5 specification. Hence, it would still be rendered to client-side as a DOM attribute even if the browser doesn’t support it.
- Parameters:
playsinline- whether to enable the playsinline function.
-
getPlaybackRate
public double getPlaybackRate()Returns the video play speed.Default: 1.0.
- Returns:
- video play speed.
-
setPlaybackRate
public void setPlaybackRate(double playbackRate) Sets the video play speed, type of value is in double, valid value is depending on browser.- Parameters:
playbackRate- video play speed.
-
isClipToFit
public boolean isClipToFit()Return whether to clip video when the source size doesn't fit the tag size setting, for example: if video source is 1280 * 720, but the video tag is
, it will cut off the sides of the video, preserving the aspect ratio, and also filling in the space.<video width="1000px" height="720px" />Default: false.
- Returns:
- whether to clip video when the source size doesn't fit the tag size setting.
-
setClipToFit
public void setClipToFit(boolean clipToFit) Set whether to clip video when the source size doesn't fit the tag size setting, for example: if video source is 1280 * 720, but the video tag is
, it will cut off the sides of the video, preserving the aspect ratio, and also filling in the space.<video width="1000px" height="720px" />- Parameters:
clipToFit- whether to clip video when the source size doesn't fit the tag size setting.
-
isMuted
public boolean isMuted()Returns whether the video is muted.- Returns:
- whether the video is muted.
-
setMuted
public void setMuted(boolean muted) Sets whether to mute the video.- Parameters:
muted- whether to mute the video.
-
setPlaying
public void setPlaying(boolean playing) -
setCurrentTime
public void setCurrentTime(double currentTime) Sets which part of video to play.- Parameters:
currentTime- which part of video to play, the value is in seconds.
-
getVolume
public double getVolume()Returns the volume of video. Default: 1.0- Returns:
- the volume of video, type of value is in double, valid value is between 0.0 and 1.0.
-
setVolume
public void setVolume(double volume) Sets the volume of video.- Parameters:
volume- the volume of video, type of value is in double, valid value is between 0.0 and 1.0.
-
getContent
Note: it won't fetch what is set thru by
setSrc(java.lang.String). It simply returns what is passed tosetContent(org.zkoss.video.Video).Default: null.
- Returns:
- the content set by
setContent(org.zkoss.video.Video).
-
setContent
Calling this method implies setSrc(null). In other words, the last invocation of
setContent(org.zkoss.video.Video)overrides the previoussetSrc(java.lang.String), if any.- Parameters:
content- sets the content directly.- See Also:
-
play
public void play()Play the video at the client. -
pause
public void pause()Pause the video at the client. -
stop
public void stop()Stop the video at the client. -
isPlaying
public boolean isPlaying()Return whether the video is playing.- Returns:
- true if video is playing;
-
isPaused
public boolean isPaused()Return whether the video is paused.- Returns:
- true if video is paused;
-
isStopped
public boolean isStopped()Return whether the video is stopped. While the video is ended, also means it is stopped.- Returns:
- true if video is stopped or ended;
-
isEnded
public boolean isEnded()Return whether the video is ended.- Returns:
- true if video is ended;
- Since:
- 9.6.0
-
renderProperties
Description copied from class:HtmlBasedComponentRenders the content of this component, excluding the enclosing tags and children.- Overrides:
renderPropertiesin classXulElement- Throws:
IOException
-
beforeChildAdded
Description copied from class:AbstractComponentDefault: does nothing.- Specified by:
beforeChildAddedin interfaceComponentCtrl- Overrides:
beforeChildAddedin classAbstractComponent- Parameters:
child- the child to be added (never null).insertBefore- another child component that the new child will be inserted before it. If null, the new child will be the last child.- See Also:
-
getExtraCtrl
Description copied from class:HtmlBasedComponentReturns the client control for this component. It is used only by component developers.Default: creates an instance of
HtmlBasedComponent.ExtraCtrl.- Specified by:
getExtraCtrlin interfaceComponentCtrl- Overrides:
getExtraCtrlin classHtmlBasedComponent- Returns:
- null if no special handling required. If the component
requires some special controls, it could return an object that
implements one or several interfaces in the org.zkoss.zk.ui.ext.render
package.
For example,
Cropper. - See Also:
-
updateByClient
Description copied from class:AbstractComponentCalled when the widget running at the client asks the server to update a value. The update is caused by an AU request namedsetAttr(by invoking zk.Widget's smartUpdate at client).By default, it does nothing but log a warning message, since it is not safe to allow the client to update a field arbitrary.
However, if you'd like to allow the update for a particular component you could do one of the following
- For component developers: override this method to update the field
directly. For example,
protected void updateByClient(String name, Object value) { if ("disabled".equals(name)) setDisabled(name, ((Boolean)value).booleanValue()); else super.updateByClient(name, value); - For application developers: set an attribute called
org.zkoss.zk.ui.updateByClientto be true. Then, this method will use reflection to find out the setter to update the value. Nothing happens if the method is not found.
Notice: this method will invoke
AbstractComponent.disableClientUpdate(boolean)to disable any update to the client, when calling the setter.If you want to enable the client update for all instances of a given component (though not recommended for the security reason), you could refer to here.
See also zk.Widget.smartUpdate().
- Overrides:
updateByClientin classAbstractComponent
- For component developers: override this method to update the field
directly. For example,
-
service
Description copied from class:HtmlBasedComponentProcesses an AU request.Default: it handles onClick, onDoubleClick, onRightClick onMove, onSize, onZIndex.
- Specified by:
servicein interfaceComponentCtrl- Overrides:
servicein classHtmlBasedComponenteverError- whether any error ever occurred before processing this request.- See Also:
-