Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

RTCDTMFSender: tonechange event

BaselineWidely available

Thetonechange event is sent to anRTCDTMFSender by theWebRTC API to indicate whenDTMF tones previously queued for sending (by callingRTCDTMFSender.insertDTMF()) begin and end.

To determine what tone started playing, or if a tone stopped playing, check the value of the event'stone property.

This event is not cancelable and does not bubble.

Syntax

Use the event name in methods likeaddEventListener(), or set an event handler property.

js
addEventListener("tonechange", (event) => { })ontonechange = (event) => { }

Event type

Event properties

In addition to the properties ofEvent, this interface offers the following:

RTCDTMFToneChangeEvent.toneRead only

A string specifying the tone which has begun playing, or an empty string ("") if the previous tone has finished playing.

Examples

This example establishes a handler for thetonechange event which updates an element to display the currently playing tone in its content, or, if all tones have played, the string "<none>".

This can be done usingaddEventListener():

js
dtmfSender.addEventListener(  "tonechange",  (ev) => {    let tone = ev.tone;    if (tone === "") {      tone = "&lt;none&gt;";    }    document.getElementById("playingTone").innerText = tone;  },  false,);

You can also just set theontonechange event handler property directly:

js
dtmfSender.ontonechange = (ev) => {  let tone = ev.tone;  if (tone === "") {    tone = "&lt;none&gt;";  }  document.getElementById("playingTone").innerText = tone;};

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# event-RTCDTMFSender-tonechange

Browser compatibility

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp