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

constructor();

Properties

source

source: AudioSource;

Methods

init

override init(): void;

play

Starts or resumes playback.

play(): void;

pause

Pauses playback.

pause(): void;

stop

Stops playback.

stop(): void;

setVolume

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

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