[英]How to make MP3 file play in the background of HTML/CSS/JS page?
試試這個方法
<audio id="bg_music" src="audio/silent-night.mp3" class="audio" loop autoplay> Your browser does not support the audio element. </audio>
您需要添加一個屬性autoplay
,它會完成。 您可以另外提供值autoplay=true
或autoplay=false
,但如果您不提供它,如果您只添加屬性,它會自動認為它是真的。
<audio id="bg_music" class="audio" autoplay controls loop> <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" type="audio/mp3" /> Your browser does not support the audio element. </audio>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.