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

The attribute defaultMuted that sets or returns whether the audio/video is muted by default in HTML5

黄舟
Release: 2017-11-08 11:08:10
Original
7359 people have browsed it

Example

SettingsVideoDefault mute:

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

Definition and usage

defaultMuted PropertiesSet or returnAudio/Whether the video is muted by default.

Setting this property will only change the default mute state, not the current one. To change the current muted state, use the muted attribute.

Browser support

Only Google Chrome supports the defaultMuted attribute.

Syntax

Set the defaultMuted attribute:

audio|video.defaultMuted=true|false
Copy after login

Return the defaultMuted attribute:

audio|video.defaultMuted
Copy after login

Attribute value

ValueDescription
trueIndicates that audio/video is muted by default.
falseDefault. Indicates that audio/video is not muted by default.

Technical Details

Return ValueBoolean value. true|false
Default value:false

Instance

Set video default Mute:

<!DOCTYPE html> 
<html> 
<body> 

<p>
	<button onclick="getMuted()" type="button">该视频默认是静音的吗?</button>
	<button onclick="setToMuted()" 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 getMuted() { 
	alert(myVid.defaultMuted);
} 
function setToMuted() { 
	myVid.defaultMuted = true;
	myVid.load()
} 
</script> 

</body> 
</html>
Copy after login

The above is the detailed content of The attribute defaultMuted that sets or returns whether the audio/video is muted by default 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!