x
 
<!DOCTYPE html> 
<html> 
<body> 
<video id="myVideo" width="320" height="240" controls>
  <source src="/i/photo/shanghai.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>
<p>请通过单击按钮或调整右下角的音量来更改音量。</p>
<button onclick="setHalfVolume()" type="button">将音量设置为 0.2</button>
<button onclick="setFullVolume()" type="button">将音量设置为 1.0</button>
<p id="demo"></p>
<script>
// 获取 id="myVideo" 的 video 元素
var x = document.getElementById("myVideo");
// 将 "volumechange" 事件附加到视频
x.addEventListener("volumechange", getVolume);
// 在 id="demo" 的 p 元素中显示视频的当前音量
function getVolume() { 
  document.getElementById("demo").innerHTML = "The audio volume is: " + x.volume;
} 
// 将音量设置为 0.2
function setHalfVolume() { 
  x.volume = 0.2;
} 
// 将音频音量设置为 1.0(最高)
function setFullVolume() { 
  x.volume = 1.0;
} 
</script> 
</body> 
</html>