-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
init translation of Tonechange_event #13787
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
files/zh-cn/web/api/rtcdtmfsender/tonechange_event/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,77 @@ | ||||||
--- | ||||||
title: "RTCDTMFSender: tonechange 事件" | ||||||
slug: Web/API/RTCDTMFSender/tonechange_event | ||||||
--- | ||||||
|
||||||
{{APIRef("WebRTC")}} | ||||||
|
||||||
**`tonechange`** 事件会被 [WebRTC API](/zh-CN/docs/Web/API/WebRTC_API) 发送给 {{domxref("RTCDTMFSender")}},以指示先前排队等待发送的 {{Glossary("DTMF")}} 音调(通过调用 {{domxref("RTCDTMFSender.insertDTMF()")}})何时开始和结束。 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
要确定哪个音调开始播放,或者音调是否停止播放,请检查事件的 {{domxref("RTCDTMFToneChangeEvent.tone", "tone")}} 属性的值。 | ||||||
|
||||||
此事件不可取消,也不会冒泡。 | ||||||
|
||||||
## 语法 | ||||||
|
||||||
在像 {{domxref("EventTarget.addEventListener", "addEventListener()")}} 这样的方法中使用事件名称,或设置事件处理程序属性。 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```js | ||||||
addEventListener("tonechange", (event) => {}); | ||||||
|
||||||
ontonechange = (event) => {}; | ||||||
``` | ||||||
|
||||||
## 事件类型 | ||||||
|
||||||
一个 {{domxref("RTCDTMFToneChangeEvent")}}。继承自 {{domxref("Event")}}。 | ||||||
|
||||||
{{InheritanceDiagram("RTCDTMFToneChangeEvent")}} | ||||||
|
||||||
## 事件属性 | ||||||
|
||||||
_除了 {{domxref("Event")}} 的属性外,此接口还提供以下属性:_ | ||||||
|
||||||
- {{domxref("RTCDTMFToneChangeEvent.tone")}} {{ReadOnlyInline}} | ||||||
- : 一个字符串,指定已开始播放的音调,或者如果上一个音调已完成播放,则为空字符串(`""`)。 | ||||||
|
||||||
## 示例 | ||||||
|
||||||
此示例建立了一个处理 `tonechange` 事件的处理器,它会更新一个元素以在其内容中显示当前播放的音调,或者,如果所有音调都已播放,则显示字符串 "\<none>"。 | ||||||
|
||||||
这可以使用 {{domxref("EventTarget.addEventListener", "addEventListener()")}} 来完成: | ||||||
|
||||||
```js | ||||||
dtmfSender.addEventListener( | ||||||
"tonechange", | ||||||
(ev) => { | ||||||
let tone = ev.tone; | ||||||
if (tone === "") { | ||||||
tone = "<none>"; | ||||||
} | ||||||
|
||||||
document.getElementById("playingTone").innerText = tone; | ||||||
}, | ||||||
false | ||||||
); | ||||||
``` | ||||||
|
||||||
你还可以直接设置 `ontonechange` 事件处理器属性: | ||||||
|
||||||
```js | ||||||
dtmfSender.ontonechange = (ev) => { | ||||||
let tone = ev.tone; | ||||||
if (tone === "") { | ||||||
tone = "<none>"; | ||||||
} | ||||||
|
||||||
document.getElementById("playingTone").innerText = tone; | ||||||
}; | ||||||
``` | ||||||
|
||||||
## 规范 | ||||||
|
||||||
{{Specifications}} | ||||||
|
||||||
## 浏览器兼容性 | ||||||
|
||||||
{{Compat}} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.