Class SoundManager
java.lang.Object
com.realtime.crossfire.jxclient.sound.SoundManager
Manages all sounds. Each sound has a sound type (
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 Summary
ConstructorsConstructorDescriptionSoundManager(@NotNull GuiStateManager guiStateManager, @Nullable DebugWriter debugSound) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidplayClip(@NotNull Sounds type, @NotNull CharSequence action) Plays a sound clip.voidplayMusic(@Nullable CharSequence name) Plays a background music.voidsetEffectsEnabled(boolean enabled) Sets whether sound effects are enabled.voidsetMusicEnabled(boolean enabled) Sets whether background music is enabled.voidshutdown()Terminates all sounds and free resources.voidstart()Activates this instance.
-
Constructor Details
-
SoundManager
public SoundManager(@NotNull @NotNull GuiStateManager guiStateManager, @Nullable @Nullable DebugWriter debugSound) Creates a new instance.- Parameters:
guiStateManager- the gui state manager to watchdebugSound- the writer for logging sound related information ornullto not log
-
-
Method Details
-
start
public void start()Activates this instance. -
setMusicEnabled
public void setMusicEnabled(boolean enabled) Sets whether background music is enabled.- Parameters:
enabled- whether background music is enabled
-
setEffectsEnabled
public void setEffectsEnabled(boolean enabled) Sets whether sound effects are enabled.- Parameters:
enabled- whether sound effects are enabled
-
playClip
Plays a sound clip.- Parameters:
type- the sound typeaction- the sound action name
-
playMusic
Plays a background music. If the new music name is unchanged, continue playing.- Parameters:
name- the music name
-
shutdown
Terminates all sounds and free resources.- Throws:
InterruptedException- if the current thread was interrupted while waiting for the shutdown
-