MediaStreamTrack: mute event - Web APIs 编辑

The mute event is sent to a MediaStreamTrack when the track's source is temporarily unable to provide media data. When the track is once again able to produce media output, an unmute event is sent.

During the time between the mute event and the unmute event, the value of the track's muted property is true.

Note: The condition that most people think of as "muted" (that is, a user-toggled state of silencing a track) is actually managed using the MediaStreamTrack.enabled property, for which there are no events.

BubblesNo
CancelableNo
InterfaceEvent
Event handler propertyonmute

Examples

In this example, event handlers are established for the mute and unmute events in order to detect when the media is not flowing from the source for the MediaStreamTrack referenced by musicTrack.

musicTrack.addEventListener("mute", event => {
  document.getElementById("timeline-widget").style.backgroundColor = "#aaa";
}, false);

musicTrack.addEventListener("unmute", event => {
 document.getElementById("timeline-widget").style.backgroundColor = "#fff";
}, false);

With these event handlers in place, when the track musicTrack enters its muted state, the element with the ID timeline-widget gets its background color changed to #aaa. When the track exits the muted state—detected by the arrival of an unmute event—the background color is restored to white.

You can also use the onmute event handler property to set up a handler for this event; similarly, the onunmute event handler is available for setting up a handler for the unmute event. The following example shows this:

musicTrack.onmute = event => {
  document.getElementById("timeline-widget").style.backgroundColor = "#aaa";
}

musicTrack.mute = event = > {
  document.getElementById("timeline-widget").style.backgroundColor = "#fff";
}

Specifications

SpecificationStatusComment
Media Capture and Streams
The definition of 'mute' in that specification.
Candidate RecommendationInitial specification.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:144 次

字数:4523

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文