當媒體已暫停但預計在 HTML 中恢復時執行指令碼?


當影片暫停並緩衝以便重新播放時,onwaiting 屬性將被觸發。你可以嘗試執行以下程式碼來實現onwaiting 屬性 −

示例

<!DOCTYPE html>
<html>
   <body>
      <h2 id = "test">Play</h2>
      <video id = "myid" width = "320" height = "176" controls onwaiting = "myFunction()">
         <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>
      <script>
         function myFunction() {
            document.getElementById("test").innerHTML = "Media resumes again";
         }
      </script>
   </body>
</html>

更新日期:03-Mar-2020

90 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.