Home > Web Front-end > H5 Tutorial > body text

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

黄舟
Release: 2017-11-09 09:47:12
Original
9725 people have browsed it

Example

Close the sound of video:

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

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
Copy after login

Return the muted attribute:

audio|video.muted
Copy after login

Attribute value

ValueDescription
trueIndicates that audio/video sound should be turned off.
falseDefault. Indicates that audio/video sound should be turned on.

Technical Details

Return ValueBoolean 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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template