Class SoundPlayer

java.lang.Object
org.collebol.engine.audio.SoundPlayer
All Implemented Interfaces:
AudioPlayer

public class SoundPlayer extends Object implements AudioPlayer
The SoundPlayer class manages the playback of audio sounds in the game. It handles the initialization of the OpenAL context, registration of sounds, and playing of sounds.

Usage:

     SoundPlayer soundPlayer = new SoundPlayer();
     soundPlayer.registerSound(sound);
     soundPlayer.playSound(sound.getId());
 
Since:
1.0-dev
Author:
ColleBol - contact@collebol.org
  • Constructor Details

    • SoundPlayer

      public SoundPlayer(String name)
      SoundPlayer constructor.
  • Method Details

    • registerSound

      public void registerSound(Sound sound)
      Register a sound to the player.
      Parameters:
      sound - the sound to be registerd.
    • playSound

      public void playSound(int id, Vector2D listenerPosition)
      Play a registered sound by its id.
      Parameters:
      id - the id of the sound to be played.
      listenerPosition - the position of the listener.
    • playSound

      public void playSound(int id)
      Play a registered sound by its id.

      Listener position = 0,0

      Parameters:
      id - the id of the sound to be played.
    • playModifiedSound

      public void playModifiedSound(SoundPlayer.ModifySound sound, Vector2D listenerPosition)
      Play a modified sound with custom properties to an already existing sound.
      Parameters:
      sound - the modified sound.
      listenerPosition - the position of the listener.
    • playModifiedSound

      public void playModifiedSound(SoundPlayer.ModifySound sound)
      Play a modified sound with custom properties to an already existing sound.

      Listener position = 0,0

      Parameters:
      sound - the modified sound.
    • disable

      public void disable()
    • getName

      public String getName()