API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classAudioStream

@codexo/exojs / audio / stable

Streaming long-form audio backed by an `HTMLAudioElement` - background tracks, voice-over, **and internet radio** (same mechanism, low CPU/RAM). Decoded lazily via the browser's media pipeline, so memory cost scales with the decode buffer rather than total duration. `AudioStream` is a **data descriptor**: it holds the media element and default playback parameters but does not play itself. Playback is driven by `AudioSystem.play(stream, options)`, which returns an AudioStreamVoice for fine-grained control (pause/resume, seek, loop, rate, volume, spatial). Because an `HTMLAudioElement` has a single playhead, a stream has **one active voice at a time** - playing again stops the previous voice. Routes through the system's `music` bus by default (override via PlayOptions.bus). Use Sound for short, frequently-triggered clips that benefit from pre-decoded `AudioBuffer` storage and pooled overlapping playback.

7
props
2
methods
1
events
Import
import { AudioStream } from '@codexo/exojs'

Streaming long-form audio backed by an `HTMLAudioElement` - background tracks, voice-over, **and internet radio** (same mechanism, low CPU/RAM). Decoded lazily via the browser's media pipeline, so memory cost scales with the decode buffer rather than total duration.

`AudioStream` is a **data descriptor**: it holds the media element and default playback parameters but does not play itself. Playback is driven by `AudioSystem.play(stream, options)`, which returns an AudioStreamVoice for fine-grained control (pause/resume, seek, loop, rate, volume, spatial).

Because an `HTMLAudioElement` has a single playhead, a stream has **one active voice at a time** - playing again stops the previous voice. Routes through the system's `music` bus by default (override via PlayOptions.bus).

Use Sound for short, frequently-triggered clips that benefit from pre-decoded `AudioBuffer` storage and pooled overlapping playback.

Constructors1
new(audioElement: HTMLAudioElement, options?: Partial<PlaybackOptionsCommon playback configuration for Sound and AudioStream.>): AudioStream
Methods2
Implements Playable. Called by AudioSystem.play. Stops any previously active voice (a stream has a single playhead), then starts a fresh AudioStreamVoice. Throws on a destroyed stream. The check is unconditional, not __DEV__-only: createMediaElementSource() may be called exactly once per media element, and the second call raises InvalidStateError in the browser - a hard, hard-to-trace runtime failure that a production build must not walk into.
destroy(): void
Stop the active voice and release the media graph. Terminal: the stream cannot be played again afterwards (see AudioStream.destroyed).
Properties7
loop: boolean
Default loop flag applied to new voices.
muted: boolean
Default muted flag (starts a voice at volume 0).
playbackRate: number
Default playback rate applied to new voices.
volume: number
Default volume applied to new voices. Range [0, 1].
audioElement: HTMLMediaElement
The backing HTMLAudioElement.
destroyed: boolean
true once AudioStream.destroy has run. A destroyed stream is not reusable - playing it throws. Load the asset again to get a fresh stream.
duration: number
Total media duration in seconds (NaN until metadata has loaded).
Events1
Dispatched when the media fails after the asset was already usable - a transfer that breaks mid-playback, or a decode error further into the file. A failure BEFORE the asset becomes ready fails the load instead, and is reported by Loader.onError; this signal is the runtime counterpart, so one load never appears to fail twice.
Source