RTCDTMFSender

RTCDTMFSender interface provides a mechanism for transmitting DTMF codes on a WebRTC RTCPeerConnection . You gain access to the connection's RTCDTMFSender through the RTCRtpSender.dtmf property on the audio track you wish to send DTMF with.

The primary purpose for WebRTC's DTMF support is to allow WebRTC-based communication clients to be connected to a public-switched telephone network (PSTN) or other legacy telephone service, including extant voice over IP (VoIP) services. For that reason, DTMF can't be used between two WebRTC-based devices, because there is no mechanism provided by WebRTC for receiving DTMF codes.

特性

RTCDTMFSender.toneBuffer 只读
A DOMString which contains the list of DTMF tones currently in the queue to be transmitted (tones which have already been played are no longer included in the string). See toneBuffer for details on the format of the tone buffer.

方法

RTCDTMFSender.insertDTMF()
Given a string describing a set of DTMF codes and, optionally, the duration of and inter-tone gap between the tones, insertDTMF() starts sending the specified tones. Calling insertDTMF() replaces any already-pending tones from the toneBuffer . You can abort sending queued tones by specifying an empty string ( "" ) as the set of tones to play.

Events

监听这些事件使用 addEventListener() 或通过把事件监听器赋值给 on eventname 特性为此接口。

tonechange
tonechange event is sent to the RTCDTMFSender instance's event handler to indicate that a tone has either started or stopped playing.
Also available using the ontonechange event handler property.

范例

See the article Using DTMF with WebRTC for a full example.

规范

规范 状态 Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCDTMFSender' in that specification.
候选推荐

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
RTCDTMFSender 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
canInsertDTMF Chrome 27 Edge ≤79 Firefox ? IE 不支持 No Opera Yes Safari ? WebView Android Yes Chrome Android 27 Firefox Android ? Opera Android Yes Safari iOS ? Samsung Internet Android 1.5
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
ontonechange Chrome 27 Edge ≤79 Firefox 52 IE 不支持 No Opera Yes Safari ? WebView Android Yes Chrome Android 27 Firefox Android 52 Opera Android Yes Safari iOS ? Samsung Internet Android 1.5
toneBuffer 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
tonechange event Chrome 27 Edge ≤79 Firefox 52 IE 不支持 No Opera Yes Safari ? WebView Android Yes Chrome Android 27 Firefox Android 52 Opera Android Yes Safari iOS ? Samsung Internet Android 1.5

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知

另请参阅