Gorilla.Audio.Playlist Unit Reference

Overview

The Gorilla.Audio.Playlist unit provides TGorillaAudioPlaylist, a non-visual component that manages a list of audio tracks with shuffle, loop and auto-play support. It drives an FMOD or OpenAL manager and can be used headless, programmatically or behind a custom UI.

Class Hierarchy

TComponent
  └── TGorillaAudioPlaylist

TOwnedCollection
  └── TGorillaPlaylistCollection

TCollectionItem
  └── TPlaylistItem

Enumerations

TAudioDriver

Value Description
FMOD Playback through TGorillaFMODAudioManager
OpenAL Playback through TGorillaOpenALManager

TPlaylistItem

One track of the playlist. Implemented as a TCollectionItem, so the list can be edited at design-time through the standard collection editor.

Property Type Description
Name String Display name of the track
FilePath String Path of the audio file; setting it updates Name

TGorillaPlaylistCollection

Owned collection of TPlaylistItem. Provides a typed default indexer, so Playlist[I] works, and notifies the owning playlist when items are added, removed or changed — including through the design-time editor.

Member Description
Add() Appends a new TPlaylistItem
Items[Index] Typed default indexer

TGorillaAudioPlaylist

Published Properties

Property Type Default Description
Items TGorillaPlaylistCollection — Design-time editable list of tracks
Driver TAudioDriver FMOD Backend used for playback
FMODManager TGorillaFMODAudioManager — Existing FMOD manager to drive; empty creates one internally
OpenALManager TGorillaOpenALManager — Existing OpenAL manager to drive
AutoUpdate Boolean True Polls playback itself and advances on its own
AutoPlayNext Boolean True Continues with the next track when one ends
ShuffleMode Boolean False Random play order
LoopMode Boolean False Starts over after the last track
Volume Single — Playback volume

Events

Event Type Fired when
OnPlaylistChanged TNotifyEvent Tracks were added, removed, moved or edited
OnTrackChanged TNotifyEvent A different track became current
OnPlaybackFinished TNotifyEvent The current track ended
OnStateChanged TNotifyEvent Playing / paused / stopped changed

Public Properties

Property Type Description
Playlist TGorillaPlaylistCollection The track collection
PlaylistCount Integer Number of tracks
CurrentIndex Integer Index of the current track
CurrentTrackName String Name of the current track
FMOD TGorillaFMODAudioManager The FMOD manager in use (read-only)
OpenAL TGorillaOpenALManager The OpenAL manager in use (read-only)

Manager Lifecycle

Method Description
CreateAudioHandler() Creates the internally owned manager for the active driver
DestroyAudioHandler() Releases it again

A manager linked through FMODManager / OpenALManager stays owned by the form; one created by the playlist is released by it.

Playlist Management

Method Description
AddToPlaylist(AFilename) Appends a track, returns its index
RemoveFromPlaylist(AIndex) Removes a track
ClearPlaylist() Empties the list
MovePlaylistItem(AFrom, ATo) Reorders a track
GetPlaylistItem(AIndex) Returns a TPlaylistItem

Loading

Method Description
LoadAudio(AFilename) Loads a file directly, bypassing the list
LoadAudio(AStream: TMemoryStream) Loads from a memory stream
LoadAudio(AStream: TStream) Loads from a stream

Playback

Method Description
Play() Starts or resumes playback
Pause() Pauses playback
Stop() Stops playback
PlayItem(AIndex) Plays a specific track
PlayNext() Advances to the next track
PlayPrevious() Goes back one track
IsPlaying() True while playing
IsPaused() True while paused

Position

Method Description
GetPlaybackPosition() Current position in ms
SetPlaybackPosition(AValue) Seeks to a position in ms
GetPlaybackLength() Length of the current track in ms
UpdatePlayback(out AFinished) Returns the position and reports whether the track ended

UpdatePlayback() is called periodically — either by the internal timer while AutoUpdate is on, or by your own timer when it is off. The component latches the actual start of playback, so a track is never reported as finished during the start-up window.

See Also