public class SoundManager
extends java.lang.Object
Sounds
) attached.
Sound types can be disabled (by the user) or muted (by the application). A
sound is played only if it is neither disabled nor muted.Constructor and Description |
---|
SoundManager(@NotNull GuiStateManager guiStateManager,
@Nullable DebugWriter debugSound)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
playClip(@NotNull Sounds type,
@NotNull java.lang.CharSequence action)
Plays a sound clip.
|
void |
playMusic(@Nullable java.lang.CharSequence name)
Plays a background music.
|
void |
setEffectsEnabled(boolean enabled)
Sets whether sound effects are enabled.
|
void |
setMusicEnabled(boolean enabled)
Sets whether background music is enabled.
|
void |
shutdown()
Terminates all sounds and free resources.
|
void |
start()
Activates this instance.
|
public SoundManager(@NotNull @NotNull GuiStateManager guiStateManager, @Nullable @Nullable DebugWriter debugSound)
guiStateManager
- the gui state manager to watchdebugSound
- the writer for logging sound related information or
null
to not logpublic void start()
public void setMusicEnabled(boolean enabled)
enabled
- whether background music is enabledpublic void setEffectsEnabled(boolean enabled)
enabled
- whether sound effects are enabledpublic void playClip(@NotNull @NotNull Sounds type, @NotNull @NotNull java.lang.CharSequence action)
type
- the sound typeaction
- the sound action namepublic void playMusic(@Nullable @Nullable java.lang.CharSequence name)
name
- the music namepublic void shutdown() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the current thread was interrupted while
waiting for the shutdown