HTML 中,在播放速率每次改變時執行一個指令碼?


在 HTML 中,使用 onratechange 屬性在 HTML 中播放速率每次改變時執行一個指令碼。

示例

你可以嘗試執行以下程式碼來實現 onratechange 屬性 −

 即時演示

<!DOCTYPE html>
<html>
   <body>
      <video id = "myid" width = "320" height = "176" controls onratechange = "display()">
         <source src = "/html5/foo.ogg" type = "video/ogg" />
         <source src = "/html5/foo.mp4" type = "video/mp4" />
         Your browser does not support the video element.
      </video>
      <p id="test">Change the speed of the video</p>
      <input type = "range" min = "0.1" max = "3" step = "0.2" value = "1"oninput = "update(this)">
      <script>
         function display() {
            document.getElementById("test").innerHTML = "Speed: " + document.getElementById("myid").playbackRate;
         }
         function update(ob) {
            document.getElementById("myid").playbackRate = ob.value;
         }
      </script>
   </body>
</html>

輸出

更新時間: 24-6-2020

85 次瀏覽

開啟你的 職業

完成課程獲取認證

開始
廣告