MediaStreamTrack.muted - Web APIs 编辑
The muted
read-only property of the MediaStreamTrack
interface returns a Boolean
value indicating whether or not the track is currently unable to provide media output.
To implement a way for users to mute and unmute a track, use the enabled
property. When a track is disabled by setting enabled
to false
, it generates only empty frames (audio frames in which every sample is 0, or video frames in which every pixel is black).
Syntax
const mutedFlag = track.muted
Value
A Boolean
which is true
if the track is currently muted, or false
if the track is currently unmuted.
When possible, avoid polling muted
to monitor the track's muting status. Instead, add event listeners for the mute
and unmute
events.
Example
This example counts the number of tracks in an array of MediaStreamTrack
objects which are currently muted.
let mutedCount = 0;
trackList.forEach((track) => {
if (track.muted) {
mutedCount += 1;
}
});
Specifications
Specification | Status | Comment |
---|---|---|
Media Capture and Streams The definition of 'muted' in that specification. | Candidate Recommendation | Initial definition. |
Browser compatibility
BCD tables only load in the browser
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论