insertDTMF () method on the RTCDTMFSender interface starts sending DTMF tones to the remote peer over the RTCPeerConnection . Sending of the tones is performed asynchronously, with tonechange events sent to the RTCDTMFSender every time a tone starts or ends.

As long as the connection is active, you can send tones at any time. Calling insertDTMF() will append the specified tones to the end of the current tone buffer, so that those tones play after the previously-enqueued tones.

句法

RTCDTMFSender.insertDTMF(tones[, duration[, interToneGap]]);
					

参数

tones
DOMString containing the DTMF codes to be transmitted to the recipient. Specifying an empty string as the tones parameter clears the tone buffer, aborting any currently queued tones. A "," character inserts a two second delay.
duration 可选

The amount of time, in milliseconds, that each DTMF tone should last. This value must be between 40 ms and 6000 ms (6 seconds), inclusive. The default is 100 ms.

interToneGap 可选

The length of time, in milliseconds, to wait between tones. The browser will enforce a minimum value of 30 ms (that is, if you specify a lower value, 30 ms will be used instead); the default is 70 ms.

返回值

undefined

异常

InvalidStateError

The DTMF tones couldn't be sent because the track has been stopped, or is in a read-only or inactive state.

InvalidCharacterError
One or more of the characters in tones is not valid DTMF.

范例

tbd

规范

规范 状态 注释
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCDTMFSender.insertDTMF()' 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
insertDTMF Chrome 27 Edge ≤79 Firefox 52 IE 不支持 No Opera Yes Safari ? WebView Android 4.4 Chrome Android 27 Firefox Android 52 Opera Android Yes Safari iOS ? Samsung Internet Android 1.5

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: