Class SoundManager
- java.lang.Object
-
- com.realtime.crossfire.jxclient.sound.SoundManager
-
public class SoundManager extends java.lang.ObjectManages 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
Constructors Constructor Description SoundManager(@NotNull GuiStateManager guiStateManager, @Nullable DebugWriter debugSound)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidplayClip(@NotNull Sounds type, @Nullable java.lang.String name, @NotNull java.lang.String action)Plays a sound clip.voidplayMusic(@Nullable java.lang.String 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 Detail
-
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 Detail
-
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
public void playClip(@NotNull @NotNull Sounds type, @Nullable @Nullable java.lang.String name, @NotNull @NotNull java.lang.String action)Plays a sound clip.- Parameters:
type- the sound typename- an optional prefix for the action nameaction- the sound action name
-
playMusic
public void playMusic(@Nullable @Nullable java.lang.String name)Plays a background music. If the new music name is unchanged, continue playing.- Parameters:
name- the music name
-
shutdown
public void shutdown() throws java.lang.InterruptedExceptionTerminates all sounds and free resources.- Throws:
java.lang.InterruptedException- if the current thread was interrupted while waiting for the shutdown
-
-