Current location - Music Encyclopedia - QQ Music - What is the background music code that the website can automatically loop and play?
What is the background music code that the website can automatically loop and play?

Create a new music.html page:

HTML part:

lt; audio id="bgAudio" controls="controls" autoplay="autoplay" hidden ="hidden"gt;

lt; source src="mp3/wangjie.mp3" type="audio/mp3"gt;

lt; source src="mp3/wangjie .ogg" type="audio/ogg"gt;

lt;/audiogt;

js part:

lt; script type="text/javascript "gt;

myVid=document.getElementById("bgAudio");

myVid.volume=0.2;

lt;/scriptgt;

Create a new backMusic.html page:

HTML part:

lt;frameset cols="0, 100"gt;

lt;frame src="music.html"/gt;

lt; frame src="index.html" /gt;

lt;/framesetgt;

Extension Information:

lt;audiogt; Tag defines a sound, such as music or other audio stream.

Example:

A simple HTML 5 audio:

lt; audio src="someaudio.wav"gt; Your browser does not support the audio tag . lt;/audiogt;

Attributes:

autoplay: If this attribute is present, the audio will be played as soon as it is ready.

controls: If this attribute appears, controls are displayed to the user, such as a play button.

loop: If this attribute is present, playback will restart whenever the audio ends.

preload: If this attribute appears, the audio will be loaded when the page is loaded and prepared for playback.

src: URL of the audio to be played.