#5364 Bugfix : Sound : processSound callback saved and used with loaded + mustPlay#5365
#5364 Bugfix : Sound : processSound callback saved and used with loaded + mustPlay#5365dmarcos merged 4 commits intoaframevr:masterfrom
Conversation
… before the sound was loaded will be called when loaded and not ignored anymore.
…) and loopEnd()
|
Thanks. Can you elaborate a scenario that illustrates the bug? Not sure I understand the fix. |
…the sound if a loop start was specified without an end
|
Hi dmarcos ! First, thank you for aframe, i love it. Summary : With the fix it is kept and used as expected. I also added like @mrxz suggested directly the loopStart and loopEnd API bindings. Here is some setup i tried that exposed the bug :
|
src/components/sound.js
Outdated
| this.pool = new THREE.Group(); | ||
| this.loaded = false; | ||
| this.mustPlay = false; | ||
| this.processSound = undefined; // Saved callback for the mustPlay mechanic |
There was a problem hiding this comment.
not need to explicitly assign variable to undefined. already undefined if it doesn't exist
There was a problem hiding this comment.
Where / when is this callback called? If a callback variable should be named accordingly: playSoundCallback?
There was a problem hiding this comment.
Used at line 96 : if (self.data.autoplay || self.mustPlay) { self.playSound(this.processSound); }
Yes i understand it looks useless to explicitely declare it undefined but it was giving me a chance to add a comment here. I'll remove it.
src/components/sound.js
Outdated
| if(data.loopStart != 0 && data.loopEnd == 0){ | ||
| sound.setLoopEnd(sound.buffer.duration); | ||
| } | ||
| else sound.setLoopEnd(data.loopEnd); |
There was a problem hiding this comment.
else {
sound.setLoopEnd(data.loopEnd);
}
we always use brackets for if statements
There was a problem hiding this comment.
I see, will change.
src/components/sound.js
Outdated
| if (!this.loaded) { | ||
| warn('Sound not loaded yet. It will be played once it finished loading'); | ||
| this.mustPlay = true; | ||
| if(processSound){ |
There was a problem hiding this comment.
single liner:
if (processSound) { this.processSound = processSound; }
There was a problem hiding this comment.
not sure if the if statement is necessary. probably can just do this.processSound = processSound
There was a problem hiding this comment.
True, will do.
|
Thanks so much! |
|
hi , after this change i get in the situation on line https://github.com/aframevr/aframe/blob/master/src/components/sound.js#L94 @JonathannJacobs any suggestions? |
The processSound callback given to playSound() before the sound was loaded will now be called when loaded and not ignored anymore.