HTML5 影片在 JavaScript 中全預載入


使用 oncanplaythrough 事件來完全預載入影片。你可以嘗試執行以下程式碼。

示例

<!DOCTYPE html>
<html>
   <body>
      <video id="myVideo" width="400" height="200" controls oncanplaythrough="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>
      <script>
         function display() {
            alert("Can be played without pausing for buffering.");
        }
</script>
</body>
</html>

更新於: 25-6 月-2020

683 次瀏覽

開啟你的職業生涯

完成課程獲取認證

立即開始
廣告
© . All rights reserved.