Audio
Represents a single audio clip that can be played in the world.
Represents a single audio clip that can be played in the world.
Properties
Section titled “Properties”.src
: String
Section titled “.src: String”An absolute url to an audio file, or an asset url from an audio file embedded in the app.
Currently only mp3
files are supported.
.volume
: Number
Section titled “.volume: Number”The audio volume. Defaults to 1
.
.loop
: Boolean
Section titled “.loop: Boolean”Whether the audio should loop. Defaults to false
.
.group
: Enum(‘music’, ‘sfx’)
Section titled “.group: Enum(‘music’, ‘sfx’)”The type of audio being played. Choose music
for ambient sounds or live event music etc. Choose sfx
for short sound effects that happen throughout the world.
Users are able to adjust the global audio volume for these groups independently.
Defaults to music
.
.spatial
: Boolean
Section titled “.spatial: Boolean”Whether music should be played spatially and heard by people nearby. Defaults to true
.
.distanceModel
: Enum(‘linear’, ‘inverse’, ‘expontential’)
Section titled “.distanceModel: Enum(‘linear’, ‘inverse’, ‘expontential’)”When spatial is enabled, the distance model to use. Defaults to inverse
.
.refDistance
: Number
Section titled “.refDistance: Number”When spatial is enabled, the reference distance to use. Defaults to 1
.
.maxDistance
: Number
Section titled “.maxDistance: Number”When spatial is enabled, the max distance to use. Defaults to 40
.
.rolloffFactor
: Number
Section titled “.rolloffFactor: Number”When spatial is enabled, the rolloff factor to use. Defaults to 3
.
.coneInnerAngle
: Number
Section titled “.coneInnerAngle: Number”When spatial is enabled, the cone inner angle to use. Defaults to 360
.
.coneOuterAngle
: Number
Section titled “.coneOuterAngle: Number”When spatial is enabled, the cone inner angle to use. Defaults to 360
.
.coneOuterGain
: Number
Section titled “.coneOuterGain: Number”When spatial is enabled, the cone inner angle to use. Defaults to 0
.
.currentTime
: Number
Section titled “.currentTime: Number”Gets and sets the current playback time, in seconds.
.{...Node}
Section titled “.{...Node}”Inherits all Node properties
Methods
Section titled “Methods”.play()
Section titled “.play()”Plays the audio.
NOTE: If no click gesture has ever happened within the world, playback won’t begin until it has.
.pause()
Section titled “.pause()”Pauses the audio, retaining the current time.
.stop()
Section titled “.stop()”Stops the audio and resets the time back to zero.