From 08fd752fe1d4bc7059d2197e0efb2c2c85d9edf5 Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Wed, 10 Oct 2018 00:35:29 -0700 Subject: [PATCH] fix song restart/exit --- src/components/song.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/song.js b/src/components/song.js index 99e8baf..40aee6e 100644 --- a/src/components/song.js +++ b/src/components/song.js @@ -17,11 +17,13 @@ AFRAME.registerComponent('song', { audio.crossOrigin = 'anonymous'; this.el.sceneEl.appendChild(audio); - this.el.addEventListener('cleargame', () => { - if (audio.paused) { - audio.currentTime = 0; - audio.play(); - } + this.el.addEventListener('pausemenuexit', () => { + audio.currentTime = 0; + }); + + this.el.addEventListener('pausemenurestart', () => { + audio.currentTime = 0; + audio.play(); }); audio.addEventListener('ended', () => {