audio prefetch

This commit is contained in:
Kevin Ngo
2018-10-13 08:31:06 -07:00
parent eefebb9b02
commit fa676c6c42

View File

@@ -194,14 +194,20 @@ AFRAME.registerComponent('song-preview-system', {
playSong: function (challengeId) {
if (!challengeId) { return; }
const audioanalyser = this.analyserEl.components.audioanalyser;
this.audio = this.audioStore[challengeId];
this.audio.volume = 0;
this.volumeTarget.volume = 0;
this.analyserEl.components.audioanalyser.resumeContext();
audioanalyser.resumeContext();
this.audio.currentTime = this.audio.dataset.previewStartTime;
this.audio.play();
this.fadeInAnimation.restart();
this.updateAnalyser();
// Prefetch buffer for playing.
if (audioanalyser.xhr) { audioanalyser.xhr.abort(); }
audioanalyser.fetchAudioBuffer(utils.getS3FileUrl(challengeId, 'song.ogg'));
},
updateAnalyser: function () {