<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fmpq教程(fmpq.com)</title>
</head>
<body>
<video id="myVideo" width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
您的浏览器不支持 video 标签。
</video>
<p>点击按钮获取或色织视频的音量。</p>
<button onclick="getVolume()" type="button">音量是多少?</button>
<button onclick="setHalfVolume()" type="button">设置音量值为 0.2</button>
<button onclick="setFullVolume()" type="button">设置音量值为 1.0</button>
<script>
var x = document.getElementById("myVideo");
function getVolume(){
alert(x.volume);
}
function setHalfVolume(){
x.volume = 0.2;
}
function setFullVolume(){
x.volume = 1.0;
}
</script>
</body>
</html>