Skip to Content
raavl

State and errors

Keep audio loading, waveform preparation, and playback failures separate.

Snapshot

FieldValues / meaning
sourceidle, loading, ready, error, disposed
sourceIdActive source identity or null
playbackpaused, starting, playing, buffering, ended
waveformidle, fetching, decoding, ready, error, cancelled
durationAudio duration in seconds
canPlayBrowser media readiness
volume, mutedCurrent audio settings
playbackRate, loopSpeed and full-recording loop setting
dataPrepared WaveformData or null
error, waveformErrorIndependent audio/playback and visualization errors

source: 'ready' means finite metadata is available. It does not guarantee buffering or waveform readiness. A waveform failure need not prevent valid audio playback.

RaavlError

Errors extend Error with a code, stage, optional sourceId, and optional cancellation reason.

CodeMeaning
CANCELLEDWork superseded, aborted, disposed, or cleared
DISPOSEDCommand attempted after disposal
INVALID_DATAInvalid input, peaks, annotations, theme, or options
NETWORKAudio/waveform network fetch failed
DECODEBrowser waveform decoding failed
MEDIANative media or playback failure
NOT_READYCommand needs a loaded source
DURATION_MISMATCHSupplied peaks do not match the audio duration

Stages are source, waveform, playback, lifecycle, and view. Cancellation reasons are superseded, aborted, disposed, and cleared.

Handling failures

try {
  await player.setSource(source);
} catch (error) {
  if ((error as { code?: string }).code !== "CANCELLED") showError(error);
}

// In a click handler:
void player.play().catch(showError);

Subscribe to waveformError as well as error. In React, AudioPlayer and PlayerRoot report errors through onError, and their built-in controls handle command promises. PlayerStatus displays feedback. For standalone Waveform or headless integrations, handle promises from your own commands as well. Expected cancellation is filtered by the adapter.

For cross-origin audio, check native playback and waveform CORS access separately. A host may allow streaming to an audio element while blocking the fetch needed for decoding.

On this page