Package org.zkoss.zul

Class Audio

  • 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, MediaElement

    public class Audio
    extends XulElement
    implements MediaElement
    An audio clip.

    An extension to XUL. Only works for browsers supporting HTML5 audio tag (since ZK 7.0.0).

    Author:
    tomyeh
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  Audio.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
      protected java.util.List<java.lang.String> _src  
      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
      Audio()  
      Audio​(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.sound.Audio getContent()
      Returns the content set by setContent(org.zkoss.sound.Audio).
      java.lang.Object getExtraCtrl()  
      java.lang.String getPreload()
      Returns whether and how the audio should be loaded.
      java.util.List<java.lang.String> getSrc()
      Returns the src.
      boolean isAutoplay()
      Returns whether to auto start playing the audio.
      boolean isControls()
      Returns whether to display the audio controls.
      boolean isEnded()
      Return whether the audio is ended.
      boolean isLoop()
      Returns whether to play the audio repeatedly.
      boolean isMuted()
      Returns whether to mute the audio.
      boolean isPaused()
      Return whether the audio is paused.
      boolean isPlaying()
      Return whether the audio is playing.
      boolean isStopped()
      Return whether the audio is stopped.
      void pause()
      Pauses the audio at the client.
      void play()
      Plays the audio 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 audio.
      void setContent​(org.zkoss.sound.Audio audio)
      Sets the content directly.
      void setControls​(boolean controls)
      Sets whether to display the audio controls.
      void setLoop​(boolean loop)
      Sets whether to play the audio repeatedly.
      void setMuted​(boolean muted)
      Sets whether to mute the audio.
      void setPreload​(java.lang.String preload)
      Sets whether and how the audio should be loaded.
      void setSrc​(java.lang.String src)
      Sets the src.
      void setSrc​(java.util.List<java.lang.String> src)
      Sets the source list.
      void stop()
      Stops the audio at the client, and reset its currentTime to zero.
      • 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, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
      • Methods inherited from class java.lang.Object

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

      • STOP

        public static final int STOP
        Represent the stop state
        Since:
        9.6.0
        See Also:
        Constant Field Values
      • PLAY

        public static final int PLAY
        Represent the play state
        Since:
        9.6.0
        See Also:
        Constant Field Values
      • PAUSE

        public static final int PAUSE
        Represent the pause state
        Since:
        9.6.0
        See Also:
        Constant Field Values
      • _src

        protected java.util.List<java.lang.String> _src
    • Constructor Detail

      • Audio

        public Audio()
      • Audio

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

      • 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
      • play

        public void play()
        Plays the audio at the client.
      • stop

        public void stop()
        Stops the audio at the client, and reset its currentTime to zero. (i.e. reset to begin)
      • pause

        public void pause()
        Pauses the audio at the client.
      • getSrc

        public java.util.List<java.lang.String> getSrc()
        Returns the src.

        Default: [].

      • setSrc

        public void setSrc​(java.util.List<java.lang.String> src)
        Sets the source list.
        Since:
        7.0.0
      • isAutoplay

        public boolean isAutoplay()
        Returns whether to auto start playing the audio.

        Default: false.

        Since:
        7.0.0
      • setAutoplay

        public void setAutoplay​(boolean autoplay)
        Sets whether to auto start playing the audio.
        Since:
        7.0.0
      • getPreload

        public java.lang.String getPreload()
        Returns whether and how the audio should be loaded. "none" or "metadata" or "auto" or null

        Default: null.

        Since:
        7.0.0
      • setPreload

        public void setPreload​(java.lang.String preload)
        Sets whether and how the audio should be loaded. Refer to Preload Attribute Description for details.
        Parameters:
        preload - which could be one of "none", "metadata", "auto".
        Since:
        7.0.0
      • isControls

        public boolean isControls()
        Returns whether to display the audio controls.

        Default: false.

        Since:
        7.0.0
      • setControls

        public void setControls​(boolean controls)
        Sets whether to display the audio controls.
        Since:
        7.0.0
      • isLoop

        public boolean isLoop()
        Returns whether to play the audio repeatedly.

        Default: false.

        Since:
        3.6.1
      • setLoop

        public void setLoop​(boolean loop)
        Sets whether to play the audio repeatedly.
        Since:
        3.6.1
      • isMuted

        public boolean isMuted()
        Returns whether to mute the audio.

        Default: false.

        Since:
        7.0.0
      • setMuted

        public void setMuted​(boolean muted)
        Sets whether to mute the audio.
        Since:
        7.0.0
      • isPlaying

        public boolean isPlaying()
        Return whether the audio is playing.
        Returns:
        true if audio is playing;
        Since:
        9.6.0
      • isPaused

        public boolean isPaused()
        Return whether the audio is paused.
        Returns:
        true if audio is paused;
        Since:
        9.6.0
      • isStopped

        public boolean isStopped()
        Return whether the audio is stopped. While the audio is ended, also means it is stopped.
        Returns:
        true if audio is stopped or ended;
        Since:
        9.6.0
      • isEnded

        public boolean isEnded()
        Return whether the audio is ended.
        Returns:
        true if audio 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 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