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 | |
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')
-rw-r--r-- | files/zh-cn/web/api/audioscheduledsourcenode/index.html | 81 | ||||
-rw-r--r-- | files/zh-cn/web/api/audioscheduledsourcenode/stop/index.html | 88 |
2 files changed, 169 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/audioscheduledsourcenode/index.html b/files/zh-cn/web/api/audioscheduledsourcenode/index.html new file mode 100644 index 0000000000..88af23f58d --- /dev/null +++ b/files/zh-cn/web/api/audioscheduledsourcenode/index.html @@ -0,0 +1,81 @@ +--- +title: AudioScheduledSourceNode +slug: Web/API/AudioScheduledSourceNode +tags: + - API + - Audio + - AudioScheduledSourceNode + - Interface + - Media + - NeedsTranslation + - Reference + - TopicStub + - Web Audio API + - sound +translation_of: Web/API/AudioScheduledSourceNode +--- +<div>{{APIRef("Web Audio API")}}</div> + +<p><code>AudioScheduledSourceNode</code> 接口作为web音频API的一部分,是几种具有在特定时刻开始与停止能力的音频源节点接口的父接口。更具体地来说,这个接口定义了{{domxref("AudioScheduledSourceNode.start", "start()")}} 和{{domxref("AudioScheduledSourceNode.stop", "stop()")}} 方法,以及{{domxref("AudioScheduledSourceNode.onended", "onended")}}事件</p> + + + +<div class="note"> +<p>你不能直接创建<code>AudioScheduledSourceNode</code>。而是应该使用继承于它的子接口,如{{domxref("AudioBufferSourceNode")}}, {{domxref("OscillatorNode")}}和{{domxref("ConstantSourceNode")}}.</p> +</div> + +<p>除非另有说明,基于<code>AudioScheduledSourceNode</code>节点的输出在没有播放时处于静默状态(这种状态在start()之前与stop()之后调用)。静默状态总是由一个全0值流组成。</p> + +<h2 id="Properties">Properties</h2> + +<p><em>Inherits properties from its parent interface, {{domxref("AudioNode")}}, and adds the following properties:</em></p> + +<h3 id="Event_handlers">Event handlers</h3> + +<dl> + <dt>{{domxref("AudioScheduledSourceNode.onended", "onended")}}</dt> + <dd>A function to be called when the {{event("ended")}} event is fired, indicating that the node has finished playing.</dd> +</dl> + +<h2 id="Methods">Methods</h2> + +<p><em>Inherits methods from its parent interface, {{domxref("AudioNode")}}, and adds the following methods:</em></p> + +<dl> + <dt>{{domxref("AudioScheduledSourceNode.start", "start()")}}</dt> + <dd>Schedules the node to begin playing the constant sound at the specified time. If no time is specified, the node begins playing immediately.</dd> + <dt>{{domxref("AudioScheduledSourceNode.stop", "stop()")}}</dt> + <dd>Schedules the node to stop playing at the specified time. If no time is specified, the node stops playing at once.</dd> +</dl> + +<h2 id="Specification">Specification</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', '#idl-def-AudioScheduledSourceNode', 'AudioScheduledSourceNode')}}</td> + <td>{{Spec2('Web Audio API')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<div> + + +<p>{{Compat("api.AudioScheduledSourceNode")}}</p> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API">Using the Web Audio API</a></li> + <li>{{domxref("AudioNode")}}</li> +</ul> 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> |