我們如何在 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>

更新於: 02-Mar-2020

258 瀏覽數

開啟你的職業生涯

透過完成課程獲取認證

開始
廣告
© . All rights reserved.