+ 13
How to add background music to your web page?
How to add background music to your web page?
27 Antworten
+ 15
Shahid Gul try this👇
HTML:
<audio id = "Any name">
<source src = "audio link ">
</audio>
JS:
window.addEventListener('click', function () {
var audio = document.getElementById("Any name");
audio.play();
}
click screen to hear the music👍
+ 12
I think this code check
<embed name="myMusic" src="Masgon.mp3" type="audio/midi" autostart="false" Hidden="true" loop="true"></embed>
+ 6
I hope this help , kindly up-vote if it does;
<audio autoplay loop>
<Source src="you audio source on your comp.mp3" type="audio/mp3>
Your browser does not support audio file!
</audio>
Ps: you can use the source tag for different audio type , so if one doesn't load on the website another type will load
+ 6
Like this👇
<audio autoplay>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
</audio>
If you want to add controls for audio, add "controls" into audio tag.
+ 5
make sure your audio is supported by the browser and don't use internet explorer for your projects because it does not support alot of web programming features I suggest using google chrome because it has the fastest javascript engine V8.
+ 5
<audio type="a. mp3" controls autoplay loop></audio>
+ 4
try this:
<body onload="play()">
<audio loop= 'true'>
<source src="yourAudio.mp3" type="audio/mp3">
</audio>
<script>
let x = document.querySelector('audio');
function play(){
x.play();
}
</script>
</body>
+ 3
Simba worked
+ 3
Shahid Gul I suggest you to look at the Excellent answer by Calviղ
+ 2
https://www.sololearn.com/Discuss/159891/?ref=app
+ 2
Do a simple thing using audio tag play you music without controls . Using loop and autoplay
+ 2
ironman not working bro
+ 1
F҉R҉O҉N҉T҉ 🔚& 🔙🔚/ 𝔸𝕣𝕕𝕦𝕚𝕟𝕠 Lover it doesn't work for me
+ 1
please inform me if it doesn't work and the audio enter your own audio with the appropriate file extension
+ 1
follow me for more!
+ 1
moses sure..
+ 1
audio tag
+ 1
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
<source src="audio.ogg" type="audio/ogg">
Audio element not supported by your browser.
</audio>
+ 1
Pranjal Gupta autoplay is not working.. autoplay is disabled in chrome Firefox browsers.. we need to add j.s to enable autoplay