From b86d4ec9c016b9ca5316b5065e5494cdd3474480 Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Tue, 16 Oct 2018 12:58:14 -0700 Subject: [PATCH] wait for audio buffer source when restarting --- src/components/song.js | 1 + src/state/index.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/components/song.js b/src/components/song.js index 5d71cf1..82db593 100644 --- a/src/components/song.js +++ b/src/components/song.js @@ -124,6 +124,7 @@ AFRAME.registerComponent('song', { if (this.source) { this.source.disconnect(); } this.data.analyserEl.addEventListener('audioanalyserbuffersource', evt => { this.source = evt.detail; + this.el.sceneEl.emit('songloadfinish', null, false); if (this.data.isBeatsPreloaded) { this.source.start(); } }, ONCE); this.audioAnalyser.refreshSource(); diff --git a/src/state/index.js b/src/state/index.js index 9fa0fdf..68fce0c 100644 --- a/src/state/index.js +++ b/src/state/index.js @@ -133,6 +133,7 @@ AFRAME.registerState({ state.isBeatsPreloaded = false; state.isGameOver = false; state.isPaused = false; + state.isSongLoading = true; }, gamemenuexit: (state) => {