disconnect() 方法在 AudioNode interface lets you disconnect one or more nodes from the node on which the method is called.

句法

AudioNode.disconnect();
AudioNode.disconnect(output);
AudioNode.disconnect(destination);
AudioNode.disconnect(destination, output);
AudioNode.disconnect(destination, output, input);
					

返回值

undefined

参数

There are several versions of the disconnect() method, which accept different combinations of parameters to control which nodes to disconnect from. If no parameters are provided, all outgoing connections are disconnected.

destination 可选
AudioNode or AudioParam specifying the node or nodes to disconnect from. If this value is an AudioNode , a single node is disconnected from, with any other, optional, parameters ( output and/or input ) further limiting which inputs and/or outputs should be disconnected. If this value is an AudioParam , then the connection to that AudioParam is terminated, and the node's contributions to that computed parameter become 0 going forward once the change takes effect. If no matching connection is found, an InvalidAccessError exception is thrown.
output 可选
An index describing which output from the current AudioNode is to be disconnected. The index numbers are defined according to the number of output channels (see Audio channels ). If this parameter is out-of-bound, an IndexSizeError exception is thrown.
input 可选
An index describing which input into the specified destination AudioNode is to be disconnected. The index numbers are defined according to the number of input channels (see Audio channels ).  If this parameter is out-of-bound, an IndexSizeError exception is thrown.

异常

IndexSizeError
A value specified for input or output is invalid, referring to a node which doesn't exist or outside the permitted range.
InvalidAccessError
The node on which disconnect() was called isn't connected to the specified destination 节点。

范例

var AudioContext = window.AudioContext || window.webkitAudioContext;
var audioCtx = new AudioContext();
var oscillator = audioCtx.createOscillator();
var gainNode = audioCtx.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioCtx.destination);
gainNode.disconnect();
					

规范

规范 状态 注释
Web 音频 API
The definition of 'disconnect' 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
disconnect Chrome 14 Edge 12 Firefox 25 IE 不支持 No Opera 15 Safari 6 WebView Android Yes Chrome Android 18 Firefox Android 26 Opera Android 14 Safari iOS Yes Samsung Internet Android 1.0
destination 参数 Chrome 43 Edge ≤18 Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 43 Chrome Android 43 Firefox Android 不支持 No Opera Android ? Safari iOS ? Samsung Internet Android 4.0
input 参数 Chrome 43 Edge ≤18 Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 43 Chrome Android 43 Firefox Android 不支持 No Opera Android ? Safari iOS ? Samsung Internet Android 4.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: