Skip to main content

<audio>

Plays audio in the world, either spatial or ambient.

Props

PropTypeDescriptionDefault
srcStringURL or path to audio file in assets folder. Must be MP3.
volumeNumberVolume of the audio.1
loopBooleanWhether audio should loop when it gets to the end.false
autoplayBooleanWhether this audio should automatically start playing.false
spatialBooleanWhether to project this audio spatially.true
positionArrayUsed when spatial is enabled. The position of this spatial audio.[0,0,0]
distanceNumberThe distance to which falloff begins.10
rolloffNumberUsed when spatial is enabled. The factor to which falloff happens when further than distance.3
coneArrayUsed When spatial is enabled. innerAngle, outerAngle, outerGain.[360,0,0]
sourceIdStringWhen set, audio analysers in the world (cross app) can analyse this audio if they know the sourceId

Ref

FieldDescription
getPosition(vec3)Get position
setPosition(vec3)Update position
getPosition(eul)Get rotation
setRotation(eul)Update rotation
ready(fn)Callback for when audio methods below are available
duration()Returns the duration of audio
offset(value)Gets or sets the offset of audio
isPlaying()Return if audio is playing
play()Start audio
pause()Pause audio
stop()Stop audio