store song duration and length in state

This commit is contained in:
Kevin Ngo
2018-10-16 23:06:20 -07:00
parent 41a7bae85b
commit f0785650c5
3 changed files with 12 additions and 2 deletions

View File

@@ -97,6 +97,7 @@ AFRAME.registerComponent('beat-loader', {
*/
handleBeats: function (beatData) {
this.el.sceneEl.emit('beatloaderfinish', beatData, false);
// Reset variables used during playback.
// Beats spawn ahead of the song and get to the user in sync with the music.
this.beatsTimeOffset = this.data.beatAnticipationTime * 1000;

View File

@@ -177,6 +177,8 @@ AFRAME.registerComponent('song-preview-system', {
this.fadeIn();
this.updateAnalyser();
this.el.sceneEl.emit('menuselectedchallengesonglength', this.audio.duration, false);
// Prefetch buffer for playing.
if (audioanalyser.xhr) { audioanalyser.xhr.abort(); }
audioanalyser.fetchAudioBuffer(utils.getS3FileUrl(challengeId, 'song.ogg'));