diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/audioscheduledsourcenode/stop | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/audioscheduledsourcenode/stop')
-rw-r--r-- | files/zh-cn/web/api/audioscheduledsourcenode/stop/index.html | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/audioscheduledsourcenode/stop/index.html b/files/zh-cn/web/api/audioscheduledsourcenode/stop/index.html new file mode 100644 index 0000000000..a550063e13 --- /dev/null +++ b/files/zh-cn/web/api/audioscheduledsourcenode/stop/index.html @@ -0,0 +1,88 @@ +--- +title: AudioScheduledSourceNode.stop() +slug: Web/API/AudioScheduledSourceNode/stop +translation_of: Web/API/AudioScheduledSourceNode/stop +--- +<p>{{ APIRef("Web Audio API") }}</p> + +<p> {{domxref("AudioScheduledSourceNode")}} 上的<code>stop()</code>方法将声音安排在指定的时间停止播放。如果没有指定时间,声音将立即停止播放。</p> + +<p>每次在同一个节点上调用 <code>stop()</code> 时,指定的时间将替换任何未发生的计划停止时间。如果节点已经停止,则此方法无效。 </p> + +<div class="note"> +<p><strong>注意:</strong> 如果计划的停止时间发生在节点计划的开始时间之前,则节点永远不会开始运行。</p> +</div> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><em>AudioScheduledSourceNode</em>.stop([<em>when</em>]); +</pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><code>when</code> {{optional_inline}}</dt> + <dd>声音停止播放的时间,单位为秒。 这个值在 {{domxref("AudioContext")}} 用于其 {{domxref("AudioContext.currentTime", "currentTime")}} 属性的同一时间坐标系统中指定。 省略这个参数,设置为0或者负值都会立即停止播放。</dd> +</dl> + +<h3 id="Return_value">Return value</h3> + +<p>{{jsxref("undefined")}}</p> + +<h3 id="Exceptions">Exceptions</h3> + +<dl> + <dt><code>InvalidStateNode</code></dt> + <dd>节点还没有通过调用{{domxref("AudioScheduledSourceNode.start", "start()")}}方法被播放.</dd> + <dt><code>RangeError</code></dt> + <dd>当 <code>when</code> 指定为负值时。</dd> +</dl> + +<h2 id="Example" name="Example">Example</h2> + +<p>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 {{domxref("AudioContext.currentTime")}} and adding 1 second.</p> + +<pre class="brush: js">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);</pre> + +<h2 id="Parameters" name="Parameters">Specifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('Web Audio API', '#widl-AudioScheduledSourceNode-stop-void-double-when', 'stop()')}}</td> + <td>{{Spec2('Web Audio API')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<div> + + +<p>{{Compat("api.AudioScheduledSourceNode.stop")}}</p> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/Web_Audio_API/Using_Web_Audio_API">Using the Web Audio API</a></li> + <li>{{domxref("AudioScheduledSourceNode.start", "start()")}}</li> + <li>{{domxref("AudioScheduledSourceNode")}}</li> + <li>{{domxref("AudioBufferSourceNode")}}</li> + <li>{{domxref("ConstantSourceNode")}}</li> + <li>{{domxref("OscillatorNode")}}</li> +</ul> |