Note: This documentation is for the old 0.2.0 version of A-Frame. Check out the documentation for the current 0.7.0 version
The sound component defines the entity as a source of sound or audio. The sound component is positional and is therefore affected by the components-position.
|autoplay||Whether to automatically play sound once set.||false|
|on||An event for the entity to listen to before playing sound.||click|
|loop||Whether to loop the sound once the sound finishes playing.||false|
|src||Path to sound file.||null|
|volume||How loud to play the sound.||1|
| Event Name | Description | |————-+—————————————| | sound-ended | triggered when sound finishes playing |
sound component can also listen to an event before playing as well. For example, we might have a laughing sound play every time a monster is clicked:
For performance, it is recommended to block the scene on the sound asset to preload and cache. We can do so through the asset management system:
To programmatically pause or resume a playing sound, we can tell the entity to pause or resume:
Or to pause only the sound:
.play() on either the entity or the sound component to resume.