Play the sound given by the src
or res
property from the location
of the entity.
Properties:
Name | Type | Default | Description |
---|---|---|---|
res |
string | The resource identifier for a built-in sound clip. |
|
src |
string | A URL to an external sound clip. The sound can be in WAV, OGG or MP3 format. However. only WAV is supported on all platforms. MP3 is supported on Gear VR and OGG is supported on desktop. |
|
on |
string | The name of the event that will play this sound clip. |
|
loop |
boolean | false | Tells the clip to loop back to the beginning of the clip once it's finished. |
autoplay |
boolean | false | Tells the clip to start automatically when
the scene loads, instead of waiting for |
oneshot |
boolean | false | Tells the clip to clean itself up when it finishes playing. Allows for overlapping instances of the sound. |
volume |
number | 1 | The volume of the clip, from [0,1]. |
spatialBlend |
number | 1 | How spatialized a sound is, from [0,1]. A value of 1 will be fully localized, and the sound will pan left and right as you turn your head. A value of 0 makes it non-spatialized, and it will always be heard in both ears. |
pitch |
number | 1 | The speed multiplier for the sound. 0.5 is one octave down, and 2 is one octave up. |
minDistance |
number | 1 | Inside this distance in meters, the sound volume is at full volume. |
maxDistance |
number | 12 | If rolloff is 'logarithmic', the sound will stop attenuating at this distance. If rolloff is 'linear' or 'cosine', the sound will be silent at this distance. |
rolloff |
string | 'logarithmic' | Set this to 'linear' or 'cosine' if you want to cut sounds off at a maxDistance. |
Methods
pauseSound()
Stop the playing sound, and preserve position in clip.
playSound()
Start the sound playing.
seek(time)
Jump to a position in the clip.
Parameters:
Name | Type | Description |
---|---|---|
time |
number | The time in milliseconds to jump to. |
Events
n-sound-loaded
Fired when a sound has loaded and is ready to be played