Class TSoundList

Unit

Declaration

type TSoundList = class(TObject)

Description

Class to manage all sounds (or musics) of a game Use it if you want to register sounds once and play them as many time you need

Hierarchy

Overview

Fields

Public class var FCurrent: TSoundList;
Public var FSounds: TDictionary<integer, string>;
Public FPlayers: TObjectList<TMusicLoop>;

Methods

Public constructor Create; virtual;
Public destructor Destroy; override;
Public class function Current: TSoundList;
Public function Add(Filename: string): integer; overload;
Public function Add(SoundID: integer; Filename: string): boolean; overload;
Public function Play(SoundID: integer; Loop: boolean = false): integer;
Public procedure Stop(PlayerID: integer);
Public procedure Mute(SoundID: integer);
Public procedure MuteAll;

Properties

Public property Volume: TVolumeSonore read FVolume write SetVolume;

Description

Fields

Public class var FCurrent: TSoundList;
 
Public var FSounds: TDictionary<integer, string>;

List of sounds/musics filenames

Public FPlayers: TObjectList<TMusicLoop>;

List of TMusicLoop players used to play those sounds/musics

Methods

Public constructor Create; virtual;

Create an instance of a TSoundList or use "TSoundList.Current" to use the default one

Public destructor Destroy; override;

Destroy this instance

Public class function Current: TSoundList;

Get the instance of the default sound list to use it as a singleton

Public function Add(Filename: string): integer; overload;

Add the "filename" sound to the available sounds list and return it's index

Public function Add(SoundID: integer; Filename: string): boolean; overload;

Add the "filename" sound to the available sounds list at the SoundID position and return True if it's ok

Public function Play(SoundID: integer; Loop: boolean = false): integer;

Play the sound "SoundID", in a loop or not, and return its Player ID If the sound is played, the result is >= 0 If it returns -1, an error happened

Public procedure Stop(PlayerID: integer);

Stop a player by its PlayerID

Public procedure Mute(SoundID: integer);

Stop all players playing the SoundID

Public procedure MuteAll;

Stop all active players

Properties

Public property Volume: TVolumeSonore read FVolume write SetVolume;

Set or get volume level for all sounds / musics of this TSoundList

Delphi Game Engine (c) 2021-2025 Patrick PREMARTIN - Powered by PasDoc
Generated by PasDoc 0.16.0.