PositionalAudioComponent


class PositionalAudioComponent : Component


A Component that provides positional spatial audio playback for an Entity.

It provides an AudioOutputProvider which can be used to configure an androidx.media3.exoplayer.ExoPlayer.Builder instance for positional audio playback.

This component can only be attached to one Entity at a time. If the component is detached from an Entity, the audio will become head-locked.

Summary

Public companion functions

PositionalAudioComponent
create(session: Session, params: PointSourceParams)

Creates a PositionalAudioComponent for the given session and initializes it with the provided params.

Public functions

Unit

Updates the PointSourceParams used by the spatial audio source.

Protected functions

open Boolean
onAttach(entity: Entity)

Called by the framework when this component is being added to an Entity.

open Unit
onDetach(entity: Entity)

Called by the framework when this component is being removed from an Entity.

Public properties

AudioOutputProvider

An AudioOutputProvider that can be used to configure an androidx.media3.exoplayer.ExoPlayer.Builder for positional audio playback.

Public companion functions

create

Added in 1.0.0-alpha15
fun create(session: Session, params: PointSourceParams): PositionalAudioComponent

Creates a PositionalAudioComponent for the given session and initializes it with the provided params.

Public functions

setPointSourceParams

Added in 1.0.0-alpha15
fun setPointSourceParams(params: PointSourceParams): Unit

Updates the PointSourceParams used by the spatial audio source.

These params will apply to currently playing audio and future playback requests.

Protected functions

onAttach

protected open fun onAttach(entity: Entity): Boolean

Called by the framework when this component is being added to an Entity.

This method is triggered when Entity.addComponent is invoked. Implementations should override this method to perform setup logic or to validate if the component is compatible with the provided entity.

Parameters
entity: Entity

The Entity to which this component is being attached.

Returns
Boolean

true if the component was successfully attached; false if the entity does not support this component or if attachment failed.

onDetach

protected open fun onDetach(entity: Entity): Unit

Called by the framework when this component is being removed from an Entity.

This method is triggered when Entity.removeComponent is invoked. Implementations should override this method to release resources or undo any changes made during onAttach.

Parameters
entity: Entity

The Entity from which this component is being detached.

Public properties

audioOutputProvider

Added in 1.0.0-alpha15
val audioOutputProviderAudioOutputProvider

An AudioOutputProvider that can be used to configure an androidx.media3.exoplayer.ExoPlayer.Builder for positional audio playback.