Package org.zkoss.zul

Class Audio

All Implemented Interfaces:
Serializable, Cloneable, Component, Scope, 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:
  • Field Details

  • Constructor Details

    • Audio

      public Audio()
    • Audio

      public Audio(String src)
  • Method Details

    • service

      public void service(AuRequest request, boolean everError)
      Description copied from class: HtmlBasedComponent
      Processes an AU request.

      Default: it handles onClick, onDoubleClick, onRightClick onMove, onSize, onZIndex.

      Specified by:
      service in interface ComponentCtrl
      Overrides:
      service in class HtmlBasedComponent
      everError - whether any error ever occurred before processing this request.
      See Also:
    • 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 List<String> getSrc()
      Returns the src.

      Default: [].

    • setSrc

      public void setSrc(String src)
      Sets the src.

      Calling this method implies setContent(null). In other words, the last invocation of setSrc(java.lang.String) overrides the previous setContent(org.zkoss.sound.Audio), if any.

      See Also:
    • setSrc

      public void setSrc(List<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 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(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
    • setContent

      public void setContent(Audio audio)
      Sets the content directly.

      Default: null.

      Calling this method implies setSrc(null). In other words, the last invocation of setContent(org.zkoss.sound.Audio) overrides the previous setSrc(java.lang.String), if any.

      Parameters:
      audio - the audio to display.
      See Also:
    • getContent

      public Audio getContent()
      Returns the content set by setContent(org.zkoss.sound.Audio).

      Note: it won't fetch what is set thru by setSrc(java.lang.String). It simply returns what is passed to setContent(org.zkoss.sound.Audio).

    • renderProperties

      protected void renderProperties(ContentRenderer renderer) throws IOException
      Description copied from class: HtmlBasedComponent
      Renders the content of this component, excluding the enclosing tags and children.

      See also ZK Client-side Reference: Property Rendering

      Overrides:
      renderProperties in class XulElement
      Throws:
      IOException
    • beforeChildAdded

      public void beforeChildAdded(Component child, Component insertBefore)
      Description copied from class: AbstractComponent
      Default: does nothing.
      Specified by:
      beforeChildAdded in interface ComponentCtrl
      Overrides:
      beforeChildAdded in class AbstractComponent
      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

      public Object getExtraCtrl()
      Description copied from class: HtmlBasedComponent
      Returns the client control for this component. It is used only by component developers.

      Default: creates an instance of HtmlBasedComponent.ExtraCtrl.

      Specified by:
      getExtraCtrl in interface ComponentCtrl
      Overrides:
      getExtraCtrl in class HtmlBasedComponent
      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: