Class MusicManager


  • public class MusicManager
    extends java.lang.Object
    Plays background music. At most one background music can be concurrently active (except for fading in/out effects).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void play​(@Nullable java.lang.String name)
      Plays the given music.
      void setEnabled​(boolean enabled)
      Sets whether background music is enabled.
      void setMuted​(boolean muted)
      Sets whether background music is muted.
      void shutdown()
      Terminates a playing background music and free resources.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MusicManager

        public MusicManager​(@NotNull
                            @NotNull AudioFileLoader audioFileLoader,
                            @Nullable
                            @Nullable DebugWriter debugSound)
        Creates a new instance.
        Parameters:
        audioFileLoader - the audio file loader for loading audio files
        debugSound - the writer for logging sound related information or null to not log
    • Method Detail

      • play

        public void play​(@Nullable
                         @Nullable java.lang.String name)
        Plays the given music. If the new music name is unchanged, continue playing.
        Parameters:
        name - the music name, or null to stop playing music
      • setEnabled

        public void setEnabled​(boolean enabled)
        Sets whether background music is enabled.
        Parameters:
        enabled - whether background music is enabled
      • setMuted

        public void setMuted​(boolean muted)
        Sets whether background music is muted.
        Parameters:
        muted - whether background music is muted
      • shutdown

        public void shutdown()
        Terminates a playing background music and free resources.