The stop()
method of the AudioBufferSourceNode
Interface is used to schedule when audio buffer playback should stop.
Syntax
var source = audioCtx.createBufferSource();
source.stop(3);
Examples
The most simple example just stops the audio buffer playing immediately — you don't need to specify any parameters in this case:
source.stop();
If you want to stop the playback after a certain time, you specify a seconds value as an argument:
source.stop(3);
Note: For a more complete example showing stop()
in use, check out our AudioContext.decodeAudioData
example, You can also run the code example live, or view the source.
Parameters
- when
- The
when
parameter defines when the playback will stop. If it represents a time in the past, the playback will end immediately. If this method is called twice or more, an exception is raised.
Returns
Void.
Specification
Specification | Status | Comment |
---|---|---|
Web Audio API The definition of 'stop()' in that specification. |
Working Draft |
Browser compatibility
See also
Document Tags and Contributors
Tags:
Contributors to this page:
teoli,
chrisdavidmills
Last updated by:
teoli,