+ 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..

18th Mar 2019, 7:05 AM
Doggy
Doggy - avatar
20 odpowiedzi
+ 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(); }
18th Mar 2019, 4:26 PM
VEDANG
VEDANG - avatar
+ 20
bhomic kaushik hi, pls refer to this video: https://youtu.be/y7jOwzozumU
18th Mar 2019, 7:08 AM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 10
VEDANG well once again thanks.. I tried but didn't worked.....
18th Mar 2019, 3:51 PM
Doggy
Doggy - avatar
+ 9
bhomic kaushik rename "Ben 10 opening HD" to "Ben 10 opening HD.mp3" to make it an audio file
18th Mar 2019, 9:37 AM
VEDANG
VEDANG - avatar
+ 9
bhomic kaushik use <audio controls autoplay>
18th Mar 2019, 3:49 PM
VEDANG
VEDANG - avatar
23rd Mar 2019, 6:16 AM
Asmit joy
Asmit joy - avatar
+ 9
you can visit this for more info about autoplay policy https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
24th Mar 2019, 6:31 PM
VEDANG
VEDANG - avatar
+ 8
18th Mar 2019, 7:09 AM
Doggy
Doggy - avatar
+ 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
18th Mar 2019, 3:46 PM
Doggy
Doggy - avatar
+ 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
18th Mar 2019, 8:45 AM
Doggy
Doggy - avatar
+ 7
Ok i will try and thanks VEDANG for the reply
18th Mar 2019, 9:45 AM
Doggy
Doggy - avatar
+ 7
VEDANG thank you very much for the answer
18th Mar 2019, 4:31 PM
Doggy
Doggy - avatar
+ 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...
18th Mar 2019, 5:45 PM
Doggy
Doggy - avatar
+ 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...
18th Mar 2019, 5:58 PM
Doggy
Doggy - avatar
+ 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 ...
24th Mar 2019, 6:31 PM
Doggy
Doggy - avatar
+ 7
VEDANG thanks again... But now its not so important as i have learnt click play from you...... Thanks for that...
24th Mar 2019, 6:33 PM
Doggy
Doggy - avatar
+ 6
Thanks Rock Leone. for the reply but i was trying to use it in sololearn... Now i understood that i can't.....
24th Mar 2019, 6:14 PM
Doggy
Doggy - avatar
+ 2
Try this <audio src=music.mp3 style="display:none;" autoplay loop>audio dosent supported</audio >
18th Mar 2019, 5:08 PM
Fahim Ahmad
Fahim Ahmad - avatar
+ 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
18th Mar 2019, 8:44 PM
Ahmed Abdel Aleem
Ahmed Abdel Aleem - avatar
+ 2
<audio src= “audio.mp3” controls autoplay loop/>
20th Mar 2019, 12:41 AM
Tomás Atrat