How to add background-music in html? | SoloLearn: Learn to code for FREE!

0

How to add background-music in html?

I tried using embed tag and bgsource tag it won't work.tell me your opinion through a example so that I would understand it properly?

7/12/2020 10:17:32 AM

shubham kumar

8 Answers

New Answer

+3

Click the screen and the audio will be played https://code.sololearn.com/WfCR2cDMdj94/?ref=app

+2

Create a variable in javascript using new Audio() like this song = new Audio(); song.src="https://dl.dropbox.com/s/9thwwlf5qcl7k8s/Alan%20Walker%20-%20Faded.mp3?raw=0"; here i have used faded song Then in html section use this in body tag <body onclick="song.play()"> So when someone clicks any where in output song starts playing due to onclick event attribute.

+2

https://code.sololearn.com/WqlJtZNss9UW/?ref=app Here is my code that may help you to insert a background music.

+1

Thank you bro(Akshay Panwar) for help.

0

https://code.sololearn.com/WhvYgbmID8QV/?ref=app

0

Your most welcome shubham kumar

0

https://code.sololearn.com/WyZ2J7mGL9WA/?ref=app

0

https://code.sololearn.com/WplL4058t0hT/?ref=app