-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#5364 Bugfix : Sound : processSound callback saved and used with loaded + mustPlay #5365
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
@@ -32,6 +34,7 @@ module.exports.Component = registerComponent('sound', { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not need to explicitly assign variable to undefined. already undefined if it doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where / when is this callback called? If a callback variable should be named accordingly: playSoundCallback
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else {
sound.setLoopEnd(data.loopEnd);
}
we always use brackets for if statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, will change.
src/components/sound.js
Outdated
@@ -208,6 +219,9 @@ module.exports.Component = registerComponent('sound', { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single liner:
if (processSound) { this.processSound = processSound; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if the if statement is necessary. probably can just do this.processSound = processSound
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.