Home  >  Article  >  Web Front-end  >  The attribute muted that sets or returns whether audio/video should be muted in HTML5

The attribute muted that sets or returns whether audio/video should be muted in HTML5

黄舟
黄舟Original
2017-11-09 09:47:129672browse

Example

Close the sound of video:

myVid=document.getElementById("video1");
myVid.muted=true;

Definition and usage

muted AttributesSet or returnaudio/Whether the video should be muted (sound turned off).

Browser support

All major browsers support the muted attribute.

Note: This attribute is not supported in Internet Explorer 8 or earlier browsers.

Syntax

Set the muted attribute:

audio|video.muted=true|false

Return the muted attribute:

audio|video.muted

Attribute value

Value Description
true Indicates that audio/video sound should be turned off.
false Default. Indicates that audio/video sound should be turned on.

Technical Details

Return Value Boolean value. true|false
Default value: false

Instance

Turn off video Voice:

<!DOCTYPE html> 
<html> 
<body> 

<p>
	<button onclick="enableMute()" type="button">关闭声音</button>
	<button onclick="disableMute()" type="button">打开声音</button>
	<button onclick="checkMute()" type="button">检查静音状态</button>
</p> 
<video id="video1" controls="controls">
	<source src="/kf51/demo/mov_bbb.mp4" type="video/mp4">
	<source src="/kf51/demo/mov_bbb.ogg" type="video/ogg">
	您的浏览器不支持 video 标签。
</video>

<script>
var myVid = document.getElementById("video1");
function enableMute() { 
	myVid.muted = true;
} 
function disableMute() { 
	myVid.muted = false;
} 
function checkMute() { 
	alert(myVid.muted);
} 
</script> 

</body> 
</html>

The above is the detailed content of The attribute muted that sets or returns whether audio/video should be muted in HTML5. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn