AudioScheduledSourceNode.stop()

这篇翻译不完整。请帮忙从英语翻译这篇文章

 AudioScheduledSourceNode 上的stop()方法将声音安排在指定的时间停止播放。如果没有指定时间,声音将立即停止播放。

每次在同一个节点上调用 stop() 时,指定的时间将替换任何未发生的计划停止时间。如果节点已经停止,则此方法无效。 

注意: 如果计划的停止时间发生在节点计划的开始时间之前,则节点永远不会开始运行。

语法

AudioScheduledSourceNode.stop([when]);

参数

when 可选
声音停止播放的时间,单位为秒。 这个值在 AudioContext 用于其 currentTime 属性的同一时间坐标系统中指定。 省略这个参数,设置为0或者负值都会立即停止播放。

Return value

undefined

Exceptions

InvalidStateNode
节点还没有通过调用start()方法被播放.
RangeError
当 when 指定为负值时。

Example

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);

Specifications

Specification Status Comment
Web Audio API
stop()
Working Draft  

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 57
Full support 57
No support 14 — 56
Notes
Notes Before version 57, this event was implemented on AudioBufferSourceNode, OscillatorNode, and ConstantSourceNode, which are now children of this class.
Edge ? Firefox Full support 53IE No support NoOpera Full support 15Safari ? WebView Android Full support 57
Full support 57
No support ? — 56
Notes
Notes Before version 57, this event was implemented on AudioBufferSourceNode, OscillatorNode, and ConstantSourceNode, which are now children of this class.
Chrome Android Full support 57
Full support 57
No support 18 — 56
Notes
Notes Before version 57, this event was implemented on AudioBufferSourceNode, OscillatorNode, and ConstantSourceNode, which are now children of this class.
Edge Mobile ? Firefox Android Full support 25Opera Android Full support 15Safari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also

文档标签和贡献者

此页面的贡献者: kongtee
最后编辑者: kongtee,