Class Video

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.sys.ComponentCtrl, org.zkoss.zul.ext.MediaElement

    public class Video
    extends org.zkoss.zul.impl.XulElement
    implements org.zkoss.zul.ext.MediaElement
    A video player.

    Only works for browsers supporting HTML5 video tag

    Since:
    8.6.0
    Author:
    charlesqiu
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  Video.ExtraCtrl
      A utility class to implement HtmlBasedComponent.getExtraCtrl().
      • Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent

        org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int END
      Represent the end state
      static int PAUSE
      Represent the pause state
      static int PLAY
      Represent the play state
      static int STOP
      Represent the stop state
      • Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        _zclass
      • Fields inherited from interface org.zkoss.zk.ui.Component

        APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
      • Fields 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 
      Constructor Description
      Video()  
      Video​(java.lang.String src)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void beforeChildAdded​(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component insertBefore)  
      org.zkoss.video.Video getContent()
      Note: it won't fetch what is set thru by setSrc(java.lang.String).
      java.lang.String getCrossorigin()
      Returns the crossorigin of this video tag, could be "anonymous", "use-credentials" or null.
      java.lang.Object getExtraCtrl()  
      double getPlaybackRate()
      Returns the video play speed.
      java.lang.String getPoster()
      Returns the image source, if didn't set the image, return null.
      java.lang.String getPreload()
      Returns "none" or "metadata" or "auto" or null
      java.util.List<java.lang.String> getSrc()
      Returns the video source as List.
      double getVolume()
      Returns the volume of video.
      boolean isAutoplay()
      Returns whether to auto start playing the video.
      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
      boolean isControls()
      Returns whether to display the video controls.
      boolean isDimBackground()
      Returns whether to turn whole page to be covered by translucent black except the Video, also called theater mode.
      boolean isEnded()
      Return whether the video is ended.
      boolean isLoop()
      Returns whether to play the video repeatedly.
      boolean isMuted()
      Returns whether the video is muted.
      boolean isPaused()
      Return whether the video is paused.
      boolean isPlaying()
      Return whether the video is playing.
      boolean isPlaysinline()
      Returns the playsinline of this video tag.
      boolean isStopped()
      Return whether the video is stopped.
      void pause()
      Pause the video at the client.
      void play()
      Play the video at the client.
      protected void renderProperties​(org.zkoss.zk.ui.sys.ContentRenderer renderer)  
      void service​(org.zkoss.zk.au.AuRequest request, boolean everError)  
      void setAutoplay​(boolean autoplay)
      Sets whether to auto start playing the video.
      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
      void setContent​(org.zkoss.video.Video content)
      Calling this method implies setSrc(null).
      void setControls​(boolean controls)
      Sets whether to display the video controls.
      void setCrossorigin​(java.lang.String crossorigin)
      Could be "anonymous" or "use-credentials", an invalid string and an empty string will be handled as the "anonymous".
      void setCurrentTime​(double currentTime)
      Sets which part of video to play.
      void setDimBackground​(boolean dimBackground)
      Sets whether to turn whole page to be covered by translucent black except Video, also called theater mode.
      void setLoop​(boolean loop)
      Sets whether to play the video repeatedly.
      void setMuted​(boolean muted)
      Sets whether to mute the video.
      void setPlaybackRate​(double playbackRate)
      Sets the video play speed, type of value is in double, valid value is depending on browser.
      void setPlaying​(boolean playing)
      Ture to indicate the same as play() False to indicate the same as pause()
      void setPlaysinline​(boolean playsinline)
      Sets the playsinline of this video tag.
      void setPoster​(java.lang.String poster)
      Sets an image to be shown while the video is downloading, or until the user hits the play button.
      void setPreload​(java.lang.String preload)
      Sets whether and how the video should be loaded, which could be one of "none", "metadata", "auto".
      void setSrc​(java.lang.String src)
      Calling this method implies setContent(null).
      void setSrcList​(java.util.List<java.lang.String> src)
      Sets the source list, be invoked by the setSrc(String).
      void setVolume​(double volume)
      Sets the volume of video.
      void stop()
      Stop the video at the client.
      protected void updateByClient​(java.lang.String name, java.lang.Object 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, setTooltipAttributes
      • Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, 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, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
      • Methods 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, 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, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Video

        public Video()
      • Video

        public Video​(java.lang.String src)
    • Method Detail

      • 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

        public java.lang.String getPreload()
        Returns "none" or "metadata" or "auto" or null

        Default: null.

        Returns:
        whether and how the video should be loaded.
      • setPreload

        public void setPreload​(java.lang.String preload)
        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

        public java.lang.String getPoster()
        Returns the image source, if didn't set the image, return null.

        Default: null.

        Returns:
        the image source.
      • setPoster

        public void setPoster​(java.lang.String poster)
        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

        public java.util.List<java.lang.String> getSrc()
        Returns the video source as List.

        Default: [].

        Returns:
        the video source.
      • setSrcList

        public void setSrcList​(java.util.List<java.lang.String> src)
        Sets the source list, be invoked by the setSrc(String).
        Parameters:
        src - the source list.
      • getCrossorigin

        public java.lang.String 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

        public void setCrossorigin​(java.lang.String crossorigin)

        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
        <video width="1000px" height="720px" />
        , it will cut off the sides of the video, preserving the aspect ratio, and also filling in the space.

        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
        <video width="1000px" height="720px" />
        , it will cut off the sides of the video, preserving the aspect ratio, and also filling in the space.
        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)
        Ture to indicate the same as play() False to indicate the same as pause()
      • 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.
      • 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

        protected void renderProperties​(org.zkoss.zk.ui.sys.ContentRenderer renderer)
                                 throws java.io.IOException
        Overrides:
        renderProperties in class org.zkoss.zul.impl.XulElement
        Throws:
        java.io.IOException
      • beforeChildAdded

        public void beforeChildAdded​(org.zkoss.zk.ui.Component child,
                                     org.zkoss.zk.ui.Component insertBefore)
        Specified by:
        beforeChildAdded in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        beforeChildAdded in class org.zkoss.zk.ui.AbstractComponent
      • getExtraCtrl

        public java.lang.Object getExtraCtrl()
        Specified by:
        getExtraCtrl in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        getExtraCtrl in class org.zkoss.zk.ui.HtmlBasedComponent
      • updateByClient

        protected void updateByClient​(java.lang.String name,
                                      java.lang.Object value)
        Overrides:
        updateByClient in class org.zkoss.zk.ui.AbstractComponent
      • service

        public void service​(org.zkoss.zk.au.AuRequest request,
                            boolean everError)
        Specified by:
        service in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        service in class org.zkoss.zk.ui.HtmlBasedComponent