-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
replaying a long sound will not be muted if game is not visible #515
Comments
Just to clarify, we are not trying to prevent multiple simultaneous plays, just respect engine visibility and keep muted on simultaneous plays. |
Correct, simultaneously playing sounds is something we want. It is that subsequent plays do not respect the visibility. I think it's because the engine only keeps track the first play similar to how playing sound awaits only the first promise for completion. |
This doesn't appear to be an issue with AudioTag implementation--it prevents playing when paused on the same frame.
I believe the issue occurs in Web Audio because simultaneous plays are not tracked--therefore, only currently playing track is paused when visibility changes. When you call There's another minor bug (I think) where inside the |
…ors (#644) Closes #515 ## Context Before this change, there were multiple subtle issues with how sounds were being paused and played. Both the `AudioTag` and `WebAudio` resources treated simultaneous playing and pausing differently--they weren't consistent with each other. In addition, they both inconsistently fetched the resource via XHR and handled setting data differently as well as volume (web audio was global volume and audio tags could be individual). I basically standardized a multi-track based approach for both resources, where each "play" track keeps track of its own state. I also refactored enough where we can now share all the base controller logic for an audio resource, delegating any implementation-specific logic to new `AudioTagTrack` and `WebAudioTrack` classes. ## Tasks - [x] Test sandbox sounds - [x] Add more proper debug logging - [x] I think `Resources\Sound.ts` and my new `AbstractAudioResource` are essentially the same, I might be able to consolidate that (or at least fix the weird loading logic in `AbstractAudioResource`) - [x] Write tests against `AbstractAudioResource` class (create test mock) ## Looking for feedback: - **(Done)** Does `Track` make sense or would `Instance` make more sense? Or a different word? They essentially represent *individual* plays of a sound. But I don't want it to get confused with real multi-tracking similar to #380 ## Proposed Changes: - Create consistent implementation that handles behavior logic for both audio tags and web audio - Behavior changes: - Calling `play()` when *paused* will resume all unfinished tracks and will not trigger a new track to be played. - Calling `play()` when *not paused* will ensure current tracks play and will trigger a new track to be played. - Both audio tag and web audio tracks *can* support individual volume per play (but that is not supported in the API interface yet) - Updated type annotations to take advantage of new `AudioContext` support in TS 1.5+ - Fix audio tag pausing/resuming to properly track offsets for each "play" - Fix web audio pausing/resuming to properly track offsets for each "play" - Fix issue with web audio where playing a sound during `hidden` game event would not mute the new sound
When playing a sound with a long duration, if
sound.play()
is called more than once, each successive play of the sound (after the first one) ignores game visibility and does not mute.The text was updated successfully, but these errors were encountered: