x
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>蜜蜂教程(mifengjc.com)</title>
6
</head>
7
<body>
8
9
<p>本实例中,我们向 video 元素添加了 "onratechange" 事件。 playbackRate 属性用于设置视频的播放速度。</p>
10
<video id="myVideo" width="320" height="240" autoplay controls onratechange="myFunction()">
11
<source src="/examples/movie.mp4" type="video/mp4">
12
<source src="/examples/movie.ogg" type="video/ogg">
13
您的浏览器不支持 HTML5 video。
14
</video><br>
15
<button onclick="setPlaySpeed()" type="button">设置视频播放速度为慢速</button>
16
<script>
17
// 获取 id="myVideo" 的 video 元
18
var x = document.getElementById("myVideo");
19
// 设置当前视频的播放速度为 0.3 (慢速)
20
function setPlaySpeed() {
21
x.playbackRate = 0.3;
22
}
23
// 当播放速度改变时弹出提示窗口
24
function myFunction() {
25
alert("视频的播放速度已改变");
26
}
27
</script>
28
29
</body>
30
</html>