如何在網頁背景中播放音檔?
HTML <audio> 元素用於在網頁中新增音訊。若要在網頁的背景中播放音檔,請使用 <embed>…</embed> 元素。此外,請使用 autoplay 屬性。這樣,不論何時載入網頁,音樂都會在背景中播放。
設定寬度和高度,使播放器在網頁上隱藏起來。loop 屬性用於指定音訊是否會再重新開始。

你可以嘗試執行以下程式碼,在網頁的背景中播放音檔
範例
<!DOCTYPE html> <html> <head> <title>HTML background music</title> </head> <body> <p>The music is running in the background.</p> <p>(Song: Kalimba which is provided as a Sample Music in Windows)</p> <embed src="/html/Kalimba.mp3" loop="true" autostart="true" width="2" height="0"> </body> </html>
廣告
資料結構
網路技術
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP