Skip to content
ClassAudio System@public

WebAudioBackend ​

Browser AudioContext implementation of FlxAudioBackend.

Creates the AudioContext lazily on first play or unlockAudio(). Handles autoplay policy via a queue: sounds played before unlock are recorded and replayed on the first user gesture. By default, hiding the document suspends the context and returning resumes it.

ts
export declare class WebAudioBackend implements FlxAudioBackend

Constructors ​

ts
constructor(options?: WebAudioBackendOptions)

Constructs a new instance of the WebAudioBackend class

ParameterTypeDescription
optionsWebAudioBackendOptions-

Properties ​

PropertyModifiersTypeDescription
suspendedreadonlyboolean-
unlockedreadonlyboolean-

Methods ​

createSound() ​

ts
createSound(source: unknown, streaming: boolean): FlxSoundHandle

Parameters:

ParameterTypeDescription
sourceunknown-
streamingboolean-

Returns: FlxSoundHandle

destroy() ​

ts
destroy(): void

Returns: void

pauseAll() ​

ts
pauseAll(): void

Returns: void

resumeAll() ​

ts
resumeAll(): void

Returns: void

setGlobalMute() ​

ts
setGlobalMute(muted: boolean): void

Parameters:

ParameterTypeDescription
mutedboolean-

Returns: void

setGlobalVolume() ​

ts
setGlobalVolume(volume: number): void

Parameters:

ParameterTypeDescription
volumenumber-

Returns: void

unlockAudio() ​

ts
unlockAudio(): void

Returns: void

Released under the MIT License.