Skip to main content
Version: Latest

AudioContext

The AudioContext interface inherits from BaseAudioContext. It is responsible for supervising and managing audio-processing graph.

Constructor​

new AudioContext(options: AudioContextOptions)

interface AudioContextOptions {
sampleRate: number;
}

Errors​

Error typeDescription
NotSupportedErrorsampleRate is outside the nominal range [8000, 96000].

Properties​

AudioContext does not define any additional properties. It inherits all properties from BaseAudioContext.

Methods​

It inherits all methods from BaseAudioContext.

createMediaElementSource​

Creates MediaElementAudioSourceNode, routing media playback into the audio graph.

ParameterTypeDescription
mediaElementHTMLMediaElement (web) | AudioTagHandle (native)Media element to route into the graph. On native, wait for onLoad on <Audio> before calling.

Returns MediaElementAudioSourceNode.​

close​

Closes the audio context, releasing any system audio resources that it uses.

Returns Promise<undefined>.​

suspend​

Suspends time progression in the audio context. It is useful when your application will not use audio for a while.

Returns Promise<void>.​

resume​

Resumes a previously suspended audio context.

Returns Promise<void>.​