Class SoundItem

java.lang.Object
ch.epfl.cs107.play.window.swing.SoundItem
All Implemented Interfaces:
EventListener, LineListener

public final class SoundItem extends Object implements LineListener
Play a single sound https://bugs.openjdk.java.net/browse/JDK-8077019
  • Constructor Details

    • SoundItem

      public SoundItem(boolean loop, float volume, boolean fadeIn, boolean randomFirstStart, SwingSound sound)
      Default Sound Item constructor
      Parameters:
      loop - (boolean): indicate if the item restart on self-ending
      volume - (float): 0.0f no sound, 1.0f full audio
      fadeIn - (boolean): indicate if the song fade in until reaching its max volume
      randomFirstStart - (boolean): indicate if the first start is random in the sound
      sound - (SwingSound): the given sound to play. Not null
  • Method Details

    • start

      public void start()
      Start the sound by asking a clip and starting it
    • fadeIn

      public void fadeIn()
      Can be called to fade in this item
    • fadeOut

      public void fadeOut()
      Can be called to fade out this item
    • finish

      public void finish()
      Finish the clip. Break the loop if any : force the end of the clip
    • isFinish

      public boolean isFinish()
      Returns:
      (boolean): true if this item is finished
    • update

      public void update(LineEvent event)
      Specified by:
      update in interface LineListener