From c3e1f5d0de69c495d7dfbf353149dd0b69592f6b Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Mon, 10 Dec 2018 06:08:21 -0800 Subject: [PATCH] fix song preview / song volume issues, will add back fades later --- src/components/song-preview.js | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/components/song-preview.js b/src/components/song-preview.js index 802c363..1ab4bcb 100644 --- a/src/components/song-preview.js +++ b/src/components/song-preview.js @@ -32,7 +32,7 @@ AFRAME.registerComponent('song-preview-system', { this.audio.currentTime < 1) { this.stopSong(); } else { - this.fadeDown(); + // this.fadeDown(); } return; } @@ -169,24 +169,23 @@ AFRAME.registerComponent('song-preview-system', { playSong: function (challengeId) { if (!challengeId) { return; } - const audioanalyser = this.analyserEl.components.audioanalyser; this.audio = this.audioStore[challengeId]; - audioanalyser.resumeContext(); - this.audio.currentTime = this.audio.dataset.previewStartTime; this.audio.load(); + this.audio.volume = PREVIEW_VOLUME; + this.audio.currentTime = this.audio.dataset.previewStartTime; + this.analyserEl.setAttribute('audioanalyser', 'src', this.audio); + + const audioanalyser = this.analyserEl.components.audioanalyser; + audioanalyser.resumeContext(); + this.audio.play(); - this.fadeIn(); - this.updateAnalyser(); + // this.fadeIn(); // Prefetch buffer for playing. if (audioanalyser.xhr) { audioanalyser.xhr.abort(); } audioanalyser.fetchAudioBuffer(utils.getS3FileUrl(challengeId, 'song.ogg')); }, - updateAnalyser: function () { - this.analyserEl.setAttribute('audioanalyser', 'src', this.audio); - }, - /** * Stop song from preloading. */ @@ -204,18 +203,6 @@ AFRAME.registerComponent('song-preview-system', { } if (!index) { return; } this.preloadQueue.splice(index, 1); - }, - - fadeIn: function () { - const context = this.analyserEl.components.audioanalyser.context; - const gainNode = this.analyserEl.components.audioanalyser.gainNode; - gainNode.gain.linearRampToValueAtTime(PREVIEW_VOLUME, context.currentTime + 1.5); - }, - - fadeDown: function () { - const context = this.analyserEl.components.audioanalyser.context; - const gainNode = this.analyserEl.components.audioanalyser.gainNode; - gainNode.gain.linearRampToValueAtTime(0.05, context.currentTime + 1.5); } });