The 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.
Syntax
RTCDTMFSender.insertDTMF(tones[, duration[, interToneGap]]);
Parameters
tones- A
DOMStringcontaining the DTMF codes to be transmitted to the recipient. Specifying an empty string as thetonesparameter clears the tone buffer, aborting any currently queued tones. A "," character inserts a two second delay. durationOptional- 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.
interToneGapOptional- 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.
Return value
Exceptions
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
tonesis not valid DTMF.
Example
tbd
Specifications
| Specification | Status | Comment |
| WebRTC 1.0: Real-time Communication Between BrowsersThe definition of 'RTCDTMFSender.insertDTMF()' in that specification. | Candidate Recommendation |
Browser compatibility
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.
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
insertDTMF
|
Chrome
Full support 27 |
Edge
Full support ≤79 |
Firefox
Full support 52 |
IE
No support No |
Opera
Full support Yes |
Safari
? |
WebView Android
Full support 4.4 |
Chrome Android
Full support 27 |
Firefox Android
Full support 52 |
Opera Android
Full support Yes |
Safari iOS
? |
Samsung Internet Android
Full support 1.5 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
See also
RTCDTMFSender.insertDTMF() by Mozilla Contributors is licensed under CC-BY-SA 2.5.