-
-
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
[Closes #515] Refactor sound resources to address inconsistent behaviors #644
Conversation
/// <reference path="../Promises.ts" /> | ||
|
||
module ex { | ||
export interface IAudio { |
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.
Need to add docs
Per your feedback request and my usual mode of contribution, i will push that Track is not the right term from an audio perspective and is definitely misleading (suggests layering audio resources like in a studio recording). Instance is probably too generic. I would suggest Mix as this aligns to audio terms for the collection if settings on a play and would still fit as a term if we decide to implement multitrack. |
+100 for the awesome increase in test coverage! :) |
This is ready to merge when you all are good with the changes 👍 |
Looks solid, I like the abstraction of the audio instances |
Closes #515
Context
Before this change, there were multiple subtle issues with how sounds were being paused and played. Both the
AudioTag
andWebAudio
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
andWebAudioTrack
classes.Tasks
Resources\Sound.ts
and my newAbstractAudioResource
are essentially the same, I might be able to consolidate that (or at least fix the weird loading logic inAbstractAudioResource
)AbstractAudioResource
class (create test mock)Looking for feedback:
Track
make sense or wouldInstance
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 Support grouping of audio resources #380Proposed Changes:
play()
when paused will resume all unfinished tracks and will not trigger a new track to be played.play()
when not paused will ensure current tracks play and will trigger a new track to be played.AudioContext
support in TS 1.5+hidden
game event would not mute the new sound