+ 24
How to add a background music in html
Simply wanna add a background music so that it follows a loop and it is hidden to the Page and use an auto play option..
20 Réponses
+ 23
bhomic kaushik
Autoplay is not supported.
You should use js :
Add id "a" to <audio>
in html section:
<audio id="a" ... >
// in js section :
window.addEventListener("mouseover",play);
window.addEventListener("click",play);
function play() { document.getElementById("a").play();
}
+ 20
bhomic kaushik hi, pls refer to this video:
https://youtu.be/y7jOwzozumU
+ 10
VEDANG well once again thanks..
I tried but didn't worked.....
+ 9
bhomic kaushik
rename "Ben 10 opening HD"
to
"Ben 10 opening HD.mp3"
to make it an audio file
+ 9
bhomic kaushik use
<audio controls autoplay>
+ 9
you can visit this for more info about autoplay policy
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
+ 8
thanks Zhenis Otarbay
+ 8
The song running problem is solved but can anyone tell me about : how to add an auto play option to the music in html
+ 7
What's wrong in the below code ???
See the audio tag ...
I know its wrong .
But how to make the dropbox link work for audio....
Edit:
Solved : because of answers given
https://code.sololearn.com/W0WuML8AyNA6/?ref=app
+ 7
Ok i will try
and thanks VEDANG for the reply
+ 7
VEDANG thank you very much for the answer
+ 7
Fahim Ahmad thanks ...
Loop is working very cool and the option of display:none; is great fir hiding the music window.. but i think that autoplay option has been removed......
thanks a lot...
+ 7
VEDANG yeah it worked....
Thanks for teaching me : how to make a function to play the music when the screen is clicked anywhere....
Thanks you very much much...
+ 7
Rock Leone for example??
Plz tell!..
It will be really helpful...if its the cause ...
I have tried YouTube repeater but it doesn't works...what i think that sololearn has denied this feature to improve security ...
+ 7
VEDANG thanks again...
But now its not so important as i have learnt click play from you......
Thanks for that...
+ 6
Thanks Rock Leone. for the reply but i was trying to use it in sololearn...
Now i understood that i can't.....
+ 2
Try this <audio src=music.mp3 style="display:none;" autoplay loop>audio dosent supported</audio >
+ 2
you can use <audio autoplay loop></audio>if its not working just use js and make it just like the guy up there said and make the audio hidden i have tryd it 😉 but auto play works only in IE
+ 2
<audio src= “audio.mp3” controls autoplay loop/>