0

Adding sounds files by using js?

I'm trying to make a guitar by using floating divs as the "strings". I have the right sound files to play when each div is touched. Can anyone tell me a way to add the files. Also is it possible for the audio to overlap each other so that I can press multiple divs at once?

6th Jul 2020, 8:06 AM
Priyan Vignesh Ramesh
Priyan Vignesh Ramesh - avatar
2 Respuestas
+ 4
If you want to use those guitar sounds on Sololearn then you have to upload them on hosting service like Dropbox. Here is quick guide to do that https://www.sololearn.com/discuss/1054246/?ref=app Now, to play the audio, you can use Audio() class of Javascript. var sound1 = new Audio(); sound1.src = "https://yourlink.com/audio.mp3"; And then have a function that plays the audio and call it on an onclick event. function playAudio() { sound1.play(); }
6th Jul 2020, 8:24 AM
Raj Chhatrala
Raj Chhatrala - avatar
0
Thank you for the help!
6th Jul 2020, 9:37 AM
Priyan Vignesh Ramesh
Priyan Vignesh Ramesh - avatar