大网数据广告活动
Web 标准与前端开发

RTCDTMFSender

· 52CE 我爱测

The **`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.

WebRTC

The 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.

Instance properties

  • RTCDTMFSender.canInsertDTMF

    • : A boolean value which is true if the RTCDTMFSender is capable of sending DTMF tones, or false if it is not.
  • RTCDTMFSender.toneBuffer

    • : A string 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 RTCDTMFSender.toneBuffer for details on the format of the tone buffer.

Instance methods

  • 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

Listen to these events using EventTarget.addEventListener or by assigning an event listener to the oneventname property of this interface.

  • RTCDTMFSender.tonechange_event
    • : The tonechange event is sent to the RTCDTMFSender instance's event handler to indicate that a tone has either started or stopped playing.

Example

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

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。