Atlas Engine
API Referenceatlasatlas/audio

AudioPlayer

Component that plays an audio source and supports positional audio.

Module: atlas/audio

Component that plays an audio source and supports positional audio.

Declaration

export class AudioPlayer extends Component { ... }

Extends: Component

Constructors

Creates a new audio player.

constructor();

Properties

source

The audio source controlled by this component.

source: AudioSource;

Methods

init

Initializes the component after it is attached.

override init(): void;

play

Starts or resumes playback.

play(): void;

pause

Pauses playback.

pause(): void;

stop

Stops playback.

stop(): void;

setVolume

Sets volume.

setVolume(volume: number): void;

setLoop

Enables or disables repeated playback.

setLoop(loop: boolean): void;

setSource

Loads the audio resource for playback.

setSource(resource: Resource): void;

update

Updates the component for the current frame.

override update(dt: number): void;

setPosition

Sets the position to an absolute value.

setPosition(position: Position3d): void;

useSpatialAudio

Enables or disables positional audio for this player.

useSpatialAudio(enabled: boolean): void;

On this page