SoundFieldAudioComponent


public final class SoundFieldAudioComponent extends Component


Provides spatial audio playback for a sound field associated with an Entity.

It provides an AudioOutputProvider which can be used to configure an ExoPlayer.Builder instance for sound field audio playback. The characteristics of the sound field are defined by SoundFieldAttributes.

This component can only be attached to one Entity at a time.

Summary

Public methods

static final @NonNull SoundFieldAudioComponent

Creates a SoundFieldAudioComponent for the given session and initializes it with the provided attributes.

final @NonNull AudioOutputProvider

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

Protected methods

boolean

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

void

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

Public methods

create

Added in 1.0.0-alpha15
public static final @NonNull SoundFieldAudioComponent create(@NonNull Session session, @NonNull SoundFieldAttributes attributes)

Creates a SoundFieldAudioComponent for the given session and initializes it with the provided attributes.

getAudioOutputProvider

Added in 1.0.0-alpha15
public final @NonNull AudioOutputProvider getAudioOutputProvider()

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

Protected methods

onAttach

protected boolean onAttach(@NonNull Entity entity)

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
@NonNull 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 void onDetach(@NonNull Entity entity)

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
@NonNull Entity entity

The Entity from which this component is being detached.