如何在HTML中在音訊/影片準備好後立即開始播放它們?


使用 autoplay 屬性設定音訊或影片在頁面載入時自動播放。

示例

可以嘗試執行以下程式碼以在 HTML 中實現 autoplay 屬性 −

<!DOCTYPE HTML>
<html>
   <body>
      <video width = "300" height = "200" controls autoplay>
         <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>
   </body>
</html>

更新於:2020 年 3 月 2 日

258 次瀏覽

開啟你的職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.