Package util

Enum SoundEffects

All Implemented Interfaces:
Configuration, Serializable, Comparable<SoundEffects>, java.lang.constant.Constable, EventListener, LineListener

public enum SoundEffects extends Enum<SoundEffects> implements LineListener, Configuration
Author:
Krish Pillai

This enum provides basic sound functionality:

  • WIN
  • LOSE
  • COLLIDE
  • STARTUP
  • SHOOT
  • BOUNCE

These enumerations support play, delayed play, loop, and stop operations.

  • Enum Constant Details

    • WIN

      public static final SoundEffects WIN
      Standard win jingle
    • LOSE

      public static final SoundEffects LOSE
      Standard lose jingle
    • COLLIDE

      public static final SoundEffects COLLIDE
      Clip for collisions
    • STARTUP

      public static final SoundEffects STARTUP
      Clip for start of game
    • SHOOT

      public static final SoundEffects SHOOT
      Standard shooting noise
    • POP

      public static final SoundEffects POP
      Standard popping noise
    • BOUNCE

      public static final SoundEffects BOUNCE
      Bounce of soccer ball
    • SMASH

      public static final SoundEffects SMASH
      Smash glass bottle
  • Method Details

    • values

      public static SoundEffects[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static SoundEffects valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • play

      public void play()
      Starts play-back instantaneously. Runs in the background and is a non-blocking call.
      See Also:
    • loop

      public void loop()
      Play the audio file in an endless loop (continuously). This is a non-blocking call.
      See Also:
    • loop

      public void loop(int count)
      Loops for the specified number of times. This is a non-blocking call.
      Parameters:
      count - The number of iterations to play
      See Also:
    • rewind

      public void rewind()
      Set the current frame position to zero (the beginning)
    • loop

      public void loop(int count, long delay)
      Play the audio in an endless loop. This is a non-blocking call. Starts looping play-back from the current position. Arguments are count, specifying the number of repetitions of the loop, and the delay after which the play-back should begin.
      Parameters:
      count - The number of times for loop to run
      delay - The delay before playback begins (milliseconds)
      See Also:
    • stop

      public void stop(long delay)
      Stops play-back after specified delay. For instantaneous stoppage, use stop(). This is a non-blocking call.
      Parameters:
      delay - The delay before playback begins (milliseconds)
      See Also:
    • stop

      public void stop()
      Stops current play-back instantaneously.
      See Also:
    • play

      public void play(long delay)
      Starts play-back after specified delay. A delay of zero starts play instantly. This is a non-blocking call.
      Parameters:
      delay - Milliseconds to wait before playing.
      See Also:
    • init

      public static void init()
      Calling init() will invoke constructors on all enums. This method can be used to explicitly preload audio files and avoid in-game lag from initial loading.
      See Also:
    • update

      public void update(LineEvent event)
      Callback for the Media Player (Line listener)
      Specified by:
      update in interface LineListener
    • setVolume

      public void setVolume(float db)
      Sets the volume level of the clip. Zero db corresponds to no amplification. A negative value decreases volume. Positive value increases volume.
      Parameters:
      db - Value in decibels
      See Also: