From b6021277e0639d14e24d0160bc1f6c6a19c10a6d Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Sat, 21 Jul 2018 10:25:24 +0200 Subject: [PATCH] play-sound support IDs --- src/components/play-sound.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/play-sound.js b/src/components/play-sound.js index a3ad8bc..c7e89b5 100644 --- a/src/components/play-sound.js +++ b/src/components/play-sound.js @@ -37,7 +37,14 @@ AFRAME.registerComponent('play-sound', { init: function () { this.el.addEventListener(this.data.event, evt => { if (!this.data.enabled) { return; } - this.system.playSound(this.data.sound, this.data.volume); + this.system.playSound(this.src, this.data.volume); }); + }, + + update: function () { + this.src = this.data.sound; + if (this.data.sound.startsWith('#')) { + this.src = document.querySelector(this.data.sound).getAttribute('src'); + } } });