Skip to main content

AudioScheduledSourceNode

The AudioScheduledSourceNode interface is an AudioNode which serves as a parent interface for several types of audio source nodes. It provides ability to start and stop audio playback.

Child classes:

Methods

start

The above method schedules the node to start audio playback at specified time, if no time is given, it starts immediately. You can invoke this method only once in node's life.

ParametersTypeDescription
whennumberThe time, in seconds, at which the node will start to play.

Errors:

Error typeDescription
RangeErrorwhen is negative number.
InvalidStateErrorIf node has already been started once.

Returns undefined.

stop

The above method schedules the node to stop audio playback at specified time, if no time is given, it stops immediately. If you invoke this method multiple times on the same node before the designated stop time, the most recent call overwrites previous one.

ParametersTypeDescription
whennumberThe time, in seconds, at which the node will stop playing.

Errors:

Error typeDescription
RangeErrorwhen is negative number.
InvalidStateErrorIf node has not been started yet.

Returns undefined.

Events

Allows to set (or remove) callback that will be fired when source node has stopped playing, either because it's reached a predetermined stop time, the full duration of the audio has been performed, or because the entire buffer has been played. You can remove callback by passing null.

audioBufferSourceNode.onended = () => { //setting callback
console.log("audio ended");
};

We are Software Mansion.