java.lang.Object
com.github.hanyaeger.api.media.SoundClip
A
SoundClip
encapsulates a mp3 audio file. This file can be played once, or looped for a given amount
of times, or indefinite. The path of the mp3 file should be passed to the constructor and the file should be
available on the class path.-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
When instantiating aSoundClip
, the value of the constructor parametercycleCount
can be used to set the number of times the audio file should be played. -
Constructor Summary
-
Method Summary
-
Field Details
-
INDEFINITE
public static final int INDEFINITEWhen instantiating aSoundClip
, the value of the constructor parametercycleCount
can be used to set the number of times the audio file should be played. When the constant {#link #INDEFINITE} is used, the file be played in ann infinite loop.- See Also:
-
-
Constructor Details
-
SoundClip
Instantiate a newSoundClip
for the given file, which should be played only once.- Parameters:
path
- the path of the mp3 file. Note that this font file should be available on the Class Path and should be opened through the module descriptor.
-
SoundClip
Instantiate a newSoundClip
for the given file, which should be played for the given amount provided ofcycleCount
.- Parameters:
path
- the path of the mp3 file. Note that this font file should be available on the Class Path and should be opened through the module descriptor.cycleCount
- the number of times the audio file should be played. To loop a file indefinitely, use a cycleCount ofINDEFINITE
-
-
Method Details
-
play
public void play()Play the file. It will be played for the givencycleCount
, which is 1 by default. If the file should be looped indefinably, the cycleCount should be set to the constant valueINDEFINITE
. -
stop
public void stop()Stop playing the file. -
setVolume
public void setVolume(double volume) Set the default volume level. The new setting will only take effect on subsequent plays.- Parameters:
volume
- new default volume level for this clip
-
getVolume
public double getVolume()Get the default volume level.- Returns:
- the default volume level for this clip
-