Interface AudioClip

All Superinterfaces:
Asset

@NullMarked public interface AudioClip extends Asset
AudioClip defines the api for audio Assets.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Constant used in loop(int) to loop until stop() is called.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called when an AudioClip completes playing.
    void
    Frees up any system resources being used.
    float
     
    boolean
     
    default void
    Continues playing the AudioClip until pause or stop is called.
    void
    loop(int times)
    Continues playing the AudioClip for a number of times or until pause or stop is called.
    void
    Pauses playback.
    void
    Begins or resumes playback.
    void
    setVolume(float volume)
    Sets the volume where 0 is silent and 1 is full volume.
    void
    Stops audio playback.
  • Field Details

  • Method Details

    • isPlaying

      boolean isPlaying()
      Returns:
      True if currently playing audio
    • play

      void play()
      Begins or resumes playback.
    • pause

      void pause()
      Pauses playback. AudioClip will resume where it was paused when play is called next.
    • stop

      void stop()
      Stops audio playback. AudioClip will start from the beginning when play is called next.
    • loop

      default void loop()
      Continues playing the AudioClip until pause or stop is called.
    • loop

      void loop(int times)
      Continues playing the AudioClip for a number of times or until pause or stop is called. If times is set to CONTINUOUS_LOOPING it will play until pause or stop is called.
      Parameters:
      times - how many times the AudioClip should loop
    • getVolume

      float getVolume()
      Returns:
      volume where 0 is silent and 1 is full volume
    • setVolume

      void setVolume(float volume)
      Sets the volume where 0 is silent and 1 is full volume.
      Parameters:
      volume - the new volume
    • dispose

      void dispose()
      Frees up any system resources being used.
    • addFinishListener

      void addFinishListener(Consumer<AudioClip> callback)
      Called when an AudioClip completes playing.
      Parameters:
      callback - Consumer that provides the AudioClip that finished