Class WVideo

    • 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 video
        Indicates whether the video component is disabled.
        Specified by:
        isDisabled in interface Disableable
        Returns:
        true if the component is disabled, otherwise false.
      • setDisabled

        @Deprecated
        public void setDisabled​(boolean disabled)
        Deprecated.
        as not supported by HTML video
        Sets whether the video component is disabled.
        Specified by:
        setDisabled in interface Disableable
        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)
        Sets which playback controls (e.g. stop/start/pause) to display on the video component. The values of WVideo.Controls.NONE and WVideo.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 spec
        Sets 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 interface WComponent
        Overrides:
        isVisible in class AbstractWComponent
        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 interface WComponent
        Overrides:
        handleRequest in class AbstractWComponent
        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 interface Targetable
        Returns:
        this component's target id.
      • 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 class AbstractWComponent
        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 class AbstractWComponent
        Returns:
        the model for this component