Manages background audio playback for LiveKit agent sessions

This class handles playing ambient sounds and manages audio track publishing. It supports:

  • Continuous ambient sound playback with looping
  • Volume control and probability-based sound selection
  • Integration with LiveKit rooms and agent sessions

Note: Thinking sound not yet supported

Example

const player = new BackgroundAudioPlayer({
ambientSound: { source: BuiltinAudioClip.OFFICE_AMBIENCE, volume: 0.8 },
});

await player.start({ room, agentSession });

Constructors

Methods

  • Get the current track publication

    Returns undefined | LocalTrackPublication

  • Start the background audio system, publishing the audio track and beginning playback of any configured ambient sound.

    If ambientSound is provided (and contains file paths), they will loop automatically. If ambientSound contains AsyncIterators, they are assumed to be already infinite or looped.

    Parameters

    Returns Promise<void>