AudioElement
AudioElement
represents an audio source element that can play sound clips in the scene. It supports common playback controls, spatial proximity activation, and network synchronization.
src: string
The source URL or file path of the audio clip.
Example:
audioElement.src = 'audio/background.mp3';
console.log(audioElement.src);
controls: boolean
Enables playback controls UI (e.g., play, pause buttons) for user interaction.
Example:
audioElement.controls = true;
autoPlay: boolean
Automatically starts playback when the element is loaded.
Example:
audioElement.autoPlay = true;
loop: boolean
Enables looping playback for continuous repetition of the audio.
Example:
audioElement.loop = true;
enableOnProximity: boolean
Enables audio playback only when a listener is within a specified proximity radius.
Example:
audioElement.enableOnProximity = true;
proximityRadius: number
The radius (in scene units) around the audio source within which playback is enabled if proximity is enabled.
Example:
audioElement.proximityRadius = 10;
networkable: boolean
Indicates if the audio state and playback should be synchronized over the network.
Example:
audioElement.networkable = true;