more informational loading text (fetching v. decoding)

This commit is contained in:
Kevin Ngo
2018-10-15 16:11:17 -07:00
parent 433957f383
commit 2411b89ded
3 changed files with 29 additions and 14 deletions

View File

@@ -84,6 +84,7 @@ AFRAME.registerComponent('song', {
const data = this.data;
return new Promise(resolve => {
data.analyserEl.addEventListener('audioanalyserbuffersource', evt => {
// Finished decoding.
this.source = evt.detail;
this.source.onended = this.victory;
resolve(this.source);
@@ -91,6 +92,7 @@ AFRAME.registerComponent('song', {
this.analyserSetter.src = utils.getS3FileUrl(data.challengeId, 'song.ogg');
data.analyserEl.setAttribute('audioanalyser', this.analyserSetter);
this.audioAnalyser.xhr.addEventListener('progress', evt => {
// Finished fetching.
this.onFetchProgress(evt);
});
});
@@ -114,6 +116,7 @@ AFRAME.registerComponent('song', {
onFetchProgress: function (evt) {
const progress = evt.loaded / evt.total;
this.songLoadingIndicator.setAttribute('geometry', 'thetaLength', progress * 360);
if (progress >= 1) { this.el.sceneEl.emit('songfetchfinish', null, false); }
},
onRestart: function () {