The stop()
method of the AudioBufferSourceNode
Interface is used to schedule when audio buffer playback should stop.
var source = audioCtx.createBufferSource(); source.stop(audioCtx.currentTime + 3);
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(audioCtx.currentTime + 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.
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.Void.
Specification | Status | Comment |
---|---|---|
Web Audio API The definition of 'stop()' in that specification. | Working Draft |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 14 webkit | (Yes) | 23 | No support | 15 webkit 22 (unprefixed) | 6 webkit |
Feature | Android | Chrome | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support | No support | 28 webkit | (Yes) | 25 | 1.2 | No support | No support | 6 webkit |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/stop