Class Sound

  • All Implemented Interfaces:
    Constants

    public class Sound
    extends java.lang.Object
    implements Constants
    This class handles sound
    • Constructor Detail

      • Sound

        public Sound​(java.lang.String path)
              throws SoundException
        Load the sound
        Parameters:
        path - The path to the sound resource
        Throws:
        SoundException - Thrown if the sound file could not be loaded
    • Method Detail

      • isPlaying

        public boolean isPlaying()
                          throws SoundException
        Check if the sound clip is playing or not
        Returns:
        Returns true if the sound is playing or false otherwise
        Throws:
        SoundException - Thrown if the sound clip is null
      • setLoops

        public void setLoops​(int loops)
                      throws SoundException
        Set the number of loops to play
        Parameters:
        loops - The number of loops, should be n-1
        Throws:
        SoundException - Thrown if the sound is null
      • setVolume

        public void setVolume​(float volume)
                       throws SoundException
        Set the volume of the sound
        Parameters:
        volume - Volume between 0f and 1f
        Throws:
        SoundException - Thrown if the sound clip is null or the volume is out of range