Interface MusicService

All Known Implementing Classes:
BackgroundMusicService, EffectsMusicService

public interface MusicService
The MusicService interface is implemented by the BackgroundMusicService and the EffectMusicService Both these classes have similar function definitions, however the implementations of these functions differs based on the needs of the two types of audio played in the game.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Dispose all the currently loaded SoundFiles from memory before closing the service.
    boolean
    Check if the current MusicService is currently muted.
    boolean
    Checks if a certain SoundFile is playing.
    void
    Given a list of SoundFiles, load them all into memory.
    void
    Pause a SoundFile that is currently playing without losing the progress of that track.
    long
    play(SoundFile sound)
    A convenience method to play a sound without explicitly controlling the loop property
    long
    play(SoundFile sound, boolean looping)
    Play a given SoundFile, with it optionally looping
    void
    setMuted(boolean muted)
    Mutes the playback of a given MusicService.
    void
    stop(SoundFile sound)
    Stop a SoundFile that is currently playing.
  • Method Details

    • play

      long play(SoundFile sound, boolean looping) throws InvalidSoundFileException
      Play a given SoundFile, with it optionally looping
      Parameters:
      sound - - An enum value that implements the SoundFile interface
      looping - - A flag to control if the sound loops
      Returns:
      a long integer corresponding to the specific sound effect that is playing, will return -1 when muted or for background music.
      Throws:
      InvalidSoundFileException
    • play

      long play(SoundFile sound) throws InvalidSoundFileException
      A convenience method to play a sound without explicitly controlling the loop property
      Parameters:
      sound - An enum value that implements the SoundFile interface
      Returns:
      a long integer corresponding to the specific sound effect that is playing, will return -1 for background music or -2 for an invalid sound file
      Throws:
      InvalidSoundFileException
    • pause

      void pause(SoundFile sound) throws InvalidSoundFileException
      Pause a SoundFile that is currently playing without losing the progress of that track. If the sound is not currently playing, then this method fails transparently without throwing errors (this will be logged on the debug channel).
      Parameters:
      sound - - An enum value that implements the SoundFile interface
      Throws:
      InvalidSoundFileException
    • stop

      void stop(SoundFile sound) throws InvalidSoundFileException
      Stop a SoundFile that is currently playing. You will lose the progress of the track. If the sound is not currently playing, then this method fails transparently without throwing errors (this will be logged on the debug channel).
      Parameters:
      sound - - An enum value that implements the SoundFile interface
      Throws:
      InvalidSoundFileException
    • isMuted

      boolean isMuted()
      Check if the current MusicService is currently muted.
      Returns:
      The current mute state of the MusicService
    • setMuted

      void setMuted(boolean muted)
      Mutes the playback of a given MusicService.
      Parameters:
      muted - - The boolean state to set
    • isPlaying

      boolean isPlaying(SoundFile sound) throws InvalidSoundFileException
      Checks if a certain SoundFile is playing.
      Parameters:
      sound - - An enum value that implements the SoundFile interface
      Returns:
      The playback status of a given SoundFile
      Throws:
      InvalidSoundFileException
    • loadSounds

      void loadSounds(List<SoundFile> sounds) throws InvalidSoundFileException
      Given a list of SoundFiles, load them all into memory.
      Parameters:
      sounds - - A list of SoundFiles to be loaded into memory
      Throws:
      InvalidSoundFileException
    • dispose

      void dispose()
      Dispose all the currently loaded SoundFiles from memory before closing the service. This may be moved to the deinit method of this class so that extra steps aren't needed otherwise.