W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>在本例中,我们为 video 元素分配了 "onratechange" 事件。playbackRate 属性用于更改视频的播放速度。</p> <video id="myVideo" width="320" height="240" autoplay controls onratechange="myFunction()"> <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> // 获取 id="myVideo" 的视频元素 var x = document.getElementById("myVideo"); // 将视频的当前播放速度设置为 0.3(慢动作) function setPlaySpeed() { x.playbackRate = 0.3; } // 当视频播放速度改变时提示文字 function myFunction() { alert("The playing speed of the video was changed"); } </script> </body> </html>