Create an AudioTimeout by providing a delay and callback.
A desired delay timing in milliseconds
Optional
options: AudioTimeoutOptions = {}Additional options which modify timeout behavior
Is the timeout complete? This can be used to await the completion of the AudioTimeout if necessary. The Promise resolves to the returned value of the provided callback function.
Private
#resolveThe resolution function for the wrapping Promise.
Private
#rejectThe rejection function for the wrapping Promise.
Private
#callbackA scheduled callback function
Private
#sourceThe source node used to maintain the timeout
Static
waitSchedule a task according to some audio timeout.
A desired delay timing in milliseconds
Optional
options: AudioTimeoutOptionsAdditional options which modify timeout behavior
A promise which resolves as a returned value of the callback or void
A framework for scheduled audio events with more precise and synchronized timing than using window.setTimeout. This approach creates an empty audio buffer of the desired duration played using the shared game audio context. The onended event of the AudioBufferSourceNode provides a very precise way to synchronize audio events. For audio timing, this is preferable because it avoids numerous issues with window.setTimeout.
Example: Using a callback function
Example: Using an awaited Promise
Example: Using the wait helper