start() method on AudioScheduledSourceNode schedules a sound to begin playback at the specified time. If no time is specified, then the sound begins playing immediately.

句法

AudioScheduledSourceNode.start([when [, offset [, duration]]]);
					

参数

可选
The time, in seconds, at which the sound should begin to play. This value is specified in the same time coordinate system as the AudioContext is using for its currentTime attribute. A value of 0 (or omitting the parameter entirely) causes the sound to start playback immediately.
offset 可选

A floating-point number indicating the offset, in seconds, into the audio buffer where playback should begin. If 0 is passed then the playback will start from the beginning.

duration 可选

A floating-point number indicating the duration, in seconds, to be played. If no value is passed then the duration will be equal to the length of the audio buffer minus the offset value

返回值

undefined

异常

InvalidStateNode
The node has already been started. This error occurs even if the node is no longer running because of a prior call to stop() .
RangeError
The value specified for 为负。

范例

This example demonstrates how to create an OscillatorNode which is scheduled to start playing in 2 seconds and stop playing 1 second after that. The times are calculated by adding the desired number of seconds to the context's current time stamp returned by AudioContext.currentTime .

context = new AudioContext();
osc = context.createOscillator();
osc.connect(context.destination);
/* Schedule the start and stop times for the oscillator */
osc.start(context.currentTime + 2);
osc.stop(context.currentTime + 3);
					

规范

规范 状态 注释
Web 音频 API
The definition of 'start()' in that specification.
工作草案

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
start 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

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: