stop()
method on
AudioScheduledSourceNode
schedules a sound to cease playback at the specified time. If no time is specified, then the sound stops playing immediately.
每次调用
stop()
on the same node, the specified time replaces any previously-scheduled stop time that hasn't occurred yet. If the node has already stopped, this method has no effect.
注意: If a scheduled stop time occurs before the node's scheduled start time, the node never starts to play.
AudioScheduledSourceNode.stop([when]);
当
可选
AudioContext
is using for its
currentTime
attribute. Omitting this parameter, specifying a value of 0, or passing a negative value causes the sound to stop playback immediately.
InvalidStateNode
start()
.
RangeError
当
为负。
This example demonstrates starting an oscillator node, scheduled to begin playing at once and to stop playing in one second. The stop time is determined by taking the audio context's current time from
AudioContext.currentTime
and adding 1 second.
context = new AudioContext(); osc = context.createOscillator(); osc.connect(context.destination); /* Let's play a sine wave for one second. */ osc.start(); osc.stop(context.currentTime + 1);
| 规范 | 状态 | 注释 |
|---|---|---|
|
Web 音频 API
The definition of 'stop()' in that specification. |
工作草案 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
stop
|
Chrome 14 | Edge ≤79 | Firefox 53 | IE 不支持 No | Opera 15 | Safari ? | WebView Android Yes | Chrome Android 18 | Firefox Android 25 | Opera Android 14 | Safari iOS ? | Samsung Internet Android 1.0 |
完整支持
不支持
兼容性未知
start()
AudioScheduledSourceNode
AudioBufferSourceNode
ConstantSourceNode
OscillatorNode
AudioScheduledSourceNode
start()
stop()
AnalyserNode
AudioBuffer
AudioBufferSourceNode
AudioContext
AudioContextOptions
AudioDestinationNode
AudioListener
AudioNode
AudioNodeOptions
AudioParam
AudioProcessingEvent
AudioWorklet
AudioWorkletGlobalScope
AudioWorkletNode
AudioWorkletProcessor
BaseAudioContext
BiquadFilterNode
ChannelMergerNode
ChannelSplitterNode
ConstantSourceNode
ConvolverNode
DelayNode
DynamicsCompressorNode
GainNode
IIRFilterNode
MediaElementAudioSourceNode
MediaStreamAudioDestinationNode
MediaStreamAudioSourceNode
OfflineAudioCompletionEvent
OfflineAudioContext
OscillatorNode
PannerNode
PeriodicWave
StereoPannerNode
WaveShaperNode