avm1: Improve behavior of Sound when loadSound() has been called - #23975
avm1: Improve behavior of Sound when loadSound() has been called#23975ChrisCPI wants to merge 1 commit into
Sound when loadSound() has been called#23975Conversation
442d3c3 to
94276fb
Compare
|
If both |
|
I can look into doing that if no one disagrees with the idea. |
@kjarosh Thoughts on doing this idea? I think it could be helpful in using that to check whether the sound is external, rather than checking the transform. |
|
It depends on how this plays with the loading state, if it's unrelated to the state then yes. |
|
Putting this in draft for now - Need to do some refactoring, as it looks like the idea of the existence of a playback queue for loaded sounds is incorrect, and so I will likely remove it (effectively undoing most of #21163). What actually appears to be happening is that in FP, local sounds are loaded synchronously, so that when An easy way to observe this is to see that the var s = new Sound();
s.onLoad = function() { trace("onLoad"); }
trace("before");
s.loadSound("sound.mp3");
trace("after");In the local projector, this outputs: But when loading a remote file, it becomes asynchronous, and |
c153c58 to
6db9cb9
Compare
6db9cb9 to
dbb291c
Compare
8826c78 to
58589dd
Compare
|
Thank you for working on this! |
58589dd to
cd0e24d
Compare
Corrects several behaviors of the Sound object when loading external sound. Some of the important changes: - On desktop, when loading local sounds, execution is paused until the load is completed, matching the behavior of the FP desktop projector. - The playback queue has been removed. This was a misinterpretation of how loaded sounds behave on the desktop projector. - Added a separate `ExternalSound` struct, which will be available (and reset) whenever `loadSound` has been called. Stores several things, such as the individual sound transform for the Sound, whether it is streaming, and whether it will autoplay. - When calling `start()`, per the docs, the second argument (loops) is now ignored when the sound is streaming.
cd0e24d to
6daf70d
Compare
Description
Fixes #5019
Fixes #22572
This fixes several of the behaviors of the
Soundobject when playing external sound vialoadSound().Some of the key changes:
loadSoundis called on a Sound, it appears that it enters a state of being "separated" from its original owner (even when controlling global sound). This means it can no longer control any prior sounds that were added to it viaattachSound(and can no longer attach new sounds in this way), and it inherits its own unique sound transform, not attached to any particular display object. This has now been implemented.start()could become immediately available in this case.loadSound()again while another sound is being loaded will cancel the load, andonLoadgets called withfalsegiven as the success parameter (See theavm1/sound_load_multiple_remotetest).Testing
Several tests added to cover this.
Checklist
set_sound_transform_with_handlefunction, and the logic for the load IDs to prevent multiple loads at one time on a single Sound)