Class SoundManager

java.lang.Object
com.realtime.crossfire.jxclient.sound.SoundManager

public class SoundManager extends Object
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 Details

    • SoundManager

      public SoundManager(@NotNull @NotNull GuiStateManager guiStateManager, @Nullable @Nullable DebugWriter debugSound)
      Creates a new instance.
      Parameters:
      guiStateManager - the gui state manager to watch
      debugSound - the writer for logging sound related information or null to 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

      public void playClip(@NotNull @NotNull Sounds type, @NotNull @NotNull CharSequence action)
      Plays a sound clip.
      Parameters:
      type - the sound type
      action - the sound action name
    • playMusic

      public void playMusic(@Nullable @Nullable CharSequence name)
      Plays a background music. If the new music name is unchanged, continue playing.
      Parameters:
      name - the music name
    • shutdown

      public void shutdown() throws InterruptedException
      Terminates all sounds and free resources.
      Throws:
      InterruptedException - if the current thread was interrupted while waiting for the shutdown