<!DOCTYPE html>
<html>
<body>
<p>在此例中,我们使用 addEventListener() 方法将 "ratechange" 事件附加到 video 元素。playbackRate 属性用于更改视频的播放速度。</p>
<video id="myVideo" width="320" height="240" autoplay controls>
<source src="/i/photo/shanghai.mp4" type="video/mp4">
Your browser does not support the video tag.
</video><br>
<button onclick="setPlaySpeed()" type="button">设置视频以慢动作播放</button>
<script>
var x = document.getElementById("myVideo");
function setPlaySpeed() {
x.playbackRate = 0.3;
}
x.addEventListener("ratechange", myFunction);
function myFunction() {
alert("The playing speed of the video was changed");
}
</script>
</body>
</html>