Package visuals.audio

Class AudioMemory

java.lang.Object
visuals.audio.AudioMemory

public class AudioMemory extends Object
AudioMemory is a singleton class that handles playing and loading audio files for the game
  • Field Details

    • instance

      private static AudioMemory instance
    • easyPlayer

      private final MediaPlayer easyPlayer
    • mediumPlayer

      private final MediaPlayer mediumPlayer
    • hardPlayer

      private final MediaPlayer hardPlayer
    • leaderBoardPlayer

      private final MediaPlayer leaderBoardPlayer
    • infoPlayer

      private final MediaPlayer infoPlayer
    • currentSong

      private MediaPlayer currentSong
    • isMuted

      public boolean isMuted
      boolean toggle for playing audio
    • currentMode

      private ModeType currentMode
  • Constructor Details

    • AudioMemory

      private AudioMemory()
      private constructor, loads the audio files and sets them to loop
  • Method Details

    • getInstance

      public static AudioMemory getInstance()
      returns the instance of the AudioMemory
      Returns:
      the instance of the AudioMemory
    • playSong

      public void playSong(ModeType type)
      plays the song for given modetype
      Parameters:
      type - the modetype (such as easy, medium, leaderboards..)
    • stopSong

      public void stopSong(ModeType type)
      Stops playing the song for given modetype
      Parameters:
      type - the modetype (such as easy, medium, leaderboards..)
    • toggleMute

      public void toggleMute()
      Mutes audio
    • isMuted

      public boolean isMuted()
      boolean check for if audio is muted
      Returns:
      true if audio is muted, false otherwise
    • playTheSong

      private void playTheSong(MediaPlayer mediaPlayer)
      plays the song given as parameter
      Parameters:
      mediaPlayer - the song to be played
    • playTheIntro

      public void playTheIntro()
      plays the intro song, starts muted and fades in
    • stopTheSong

      private void stopTheSong(MediaPlayer mediaPlayer)
      stops the song given as parameter
      Parameters:
      mediaPlayer - the song to be stopped