Package view.audio

Class AudioPlayer

java.lang.Object
view.audio.AudioPlayer

public class AudioPlayer extends Object
Manages audio playback for the game, including songs and sound effects. Implements the singleton pattern to ensure a single instance.
  • Method Details

    • getInstance

      public static AudioPlayer getInstance()
      Returns the singleton instance of the AudioPlayer.
      Returns:
      the singleton instance
    • setVolume

      public void setVolume(float volume)
      Sets the volume for both songs and sound effects.
      Parameters:
      volume - the volume level to set
    • stopSong

      public void stopSong()
      Stops the current song.
    • startSong

      public void startSong()
      Starts the current song if it's not already playing.
    • playIntroSong

      public void playIntroSong()
      Plays the intro song and sets up a listener to play the main song after the intro ends.
    • playPlayingSong

      public void playPlayingSong()
      Plays the main playing song in a loop.
    • playSoundEffect

      public void playSoundEffect(int soundEffectID)
      Plays the specified sound effect.
      Parameters:
      soundEffectID - the ID of the sound effect to play