AnDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pompom454/tea/llms.txt
Use this file to discover all available pages before exploring further.
AudioTrack encapsulates a single audio resource and exposes a consistent interface for playback control, volume management, loop/mute state, fade transitions, and event handling. You obtain an AudioTrack instance via SimpleAudio.tracks.get(). Every method that changes state returns the AudioTrack itself, enabling method chaining.
AudioRunner
When you callSimpleAudio.select(selector) you get back an AudioRunner rather than a single AudioTrack. The AudioRunner exposes the exact same method surface documented below, but applies every operation to all matched tracks at once. You can chain calls on it just as you would on an individual track.
Playback methods
<AudioTrack>.play() → Promise
Begins playback of the track. Returns a Promise that resolves once playback starts, or rejects with an error on failure (e.g., autoplay policy blocked the request).
<AudioTrack>.playWhenAllowed()
Begins playback of the track immediately if allowed, or queues it to begin as soon as the player next interacts with the document. Use this instead of play() when autoplay restrictions may apply.
<AudioTrack>.pause()
Pauses playback of the track at the current position.
<AudioTrack>.stop()
Stops playback of the track and resets the playback position to the beginning.
<AudioTrack>.load()
Pauses playback and, if the track is not already loading, drops any buffered data and restarts loading from source.
<AudioTrack>.unload()
Stops playback and forces the track to drop all buffered data. Playback cannot resume until the track is reloaded.
Once unloaded,
play() will not work until load() has been called again and data has buffered.Fade methods
<AudioTrack>.fade(duration, toVol [, fromVol]) → Promise
Starts playback and fades the track from an optional starting volume to a destination volume over the given number of seconds. Returns a Promise that resolves when the fade completes normally.
When
Config.audio.pauseOnFadeToZero is true (the default), tracks faded to 0 volume are automatically paused.Number of seconds the fade should take.
Destination volume level (0–1).
Starting volume level (0–1). Defaults to the track’s current volume.
<AudioTrack>.fadeIn([duration [, fromVol]]) → Promise
Starts playback and fades the track up to 1 (loudest) over the given number of seconds.
Number of seconds for the fade.
Starting volume. Defaults to the track’s current volume.
<AudioTrack>.fadeOut([duration [, fromVol]]) → Promise
Starts playback and fades the track down to 0 (silent) over the given number of seconds.
Number of seconds for the fade.
Starting volume. Defaults to the track’s current volume.
<AudioTrack>.fadeStop()
Interrupts an in-progress fade immediately. The volume level is left wherever it was when the fade was stopped.
State methods
These methods get or set track state. When used as setters they return theAudioTrack instance for chaining.
<AudioTrack>.volume([level]) → number | AudioTrack
Gets or sets the track’s volume level (default: 1).
Volume level to set (0–1).
<AudioTrack>.mute([state]) → boolean | AudioTrack
Gets or sets the track’s mute state (default: false).
true to mute, false to unmute.<AudioTrack>.loop([state]) → boolean | AudioTrack
Gets or sets whether the track repeats after it ends (default: false).
true to loop, false to play once.<AudioTrack>.time([seconds]) → number | AudioTrack
Gets or sets the current playback position in seconds.
The position to seek to. Valid range is
0 to the track’s total duration.<AudioTrack>.duration() → number
Returns the track’s total playtime in seconds. Returns Infinity for a stream, or NaN if metadata has not yet loaded.
<AudioTrack>.remaining() → number
Returns how many seconds remain until the end of the track. Returns Infinity for a stream, or NaN if metadata is unavailable.
<AudioTrack>.clone() → AudioTrack
Returns a new independent copy of the track with its own audio element and state. Changes to the clone do not affect the original.
State query methods
All state-query methods return aboolean and take no arguments.
Load state
Load state
| Method | Returns true when… |
|---|---|
hasData() | Enough data has loaded to play through without interruption (browser estimate). |
hasMetadata() | At least the track’s metadata (duration, dimensions, etc.) has loaded. |
hasSomeData() | At least some audio data has loaded. hasData() is generally more useful. |
hasNoData() | No data has been loaded at all. |
hasSource() | At least one valid source was registered. |
isLoading() | The track is actively loading data. |
isUnloaded() | The track’s sources have been unloaded. |
Playback state
Playback state
| Method | Returns true when… |
|---|---|
isPlaying() | The track is actively playing. |
isPaused() | Playback has been paused. |
isStopped() | Playback has been stopped. |
isEnded() | The track played to its end without looping. |
isSeeking() | The track is currently seeking to a new position. |
isFading() | A fade transition is in progress. |
isFailed() | An error occurred during loading or playback. |
isUnavailable() | The track cannot play (no valid source, not loaded, or error). |
Event methods
These are thin wrappers over jQuery’s.on(), .one(), and .off() applied to the underlying audio element. They return the AudioTrack instance for chaining.
<AudioTrack>.on(events, handler) → AudioTrack
Attaches a persistent event handler to the track.
<AudioTrack>.one(events, handler) → AudioTrack
Attaches a single-use event handler that removes itself after firing once.
<AudioTrack>.off(events [, handler]) → AudioTrack
Removes one or all event handlers from the track.
Audio events
The following events fire on track elements and can be listened to viaon() / one().
| Event | Fires when… |
|---|---|
:faded | A fade completes normally. |
:fading | A fade starts. |
:stopped | Playback is stopped via .stop(). |