如何在 HTML 網頁中新增音訊播放器?


HTML <audio> 元素用於在網頁中新增音訊。要新增音訊播放器,請新增 controls 屬性。

HTML 中支援以下三種音訊格式:MP3、Wav 和 Ogg。

示例

你可以嘗試執行以下程式碼,在 HTML 網頁中新增音訊播放器

演示

<!DOCTYPE html>
<html>
   <head>
      <title>HTML audio Tag</title>
   </head>
   <body>
      <p>Click on Play button...</p>
      <p>(Song: Kalimba which is provided as a Sample Music in Windows)</p>
      <audio controls>
         <source src = "/html/Kalimba.mp3" type = "audio/mpeg">
      </audio>
   </body>
</html>

更新時間: 2020 年 6 月 16 日

5000+ 次瀏覽

啟動您的 職業生涯

完成課程即可獲得認證

開始使用
廣告