attachToContainerWithBuilder

fun attachToContainerWithBuilder(currentContext: Context, builder: AudioTrack.Builder)

Attaches spatial audio to a Container/Context using a pre-configured AudioTrack.Builder.

When to use: Use this method when the audio should follow the window/container position rather than a specific Entity. This is suitable for window-based playback scenarios (e.g., fixed-position background audio).

Usage steps:

  1. Configure spatial audio mode via spatialAudioTrackExtensionConfig.

  2. Call this method with the configured builder.

  3. Build the AudioTrack: audioTrackBuilder.build().

Parameters

currentContext

The Context/Container to attach spatial audio to.

builder

The AudioTrack.Builder with spatial audio configuration (must be pre-configured via spatialAudioTrackExtensionConfig).

Throws

IllegalStateException

if attachment fails.