+ 7

I want to add sounds in JS. Can anyone help please?

I want to add sounds in my code, but I don't know how to do it. Can anyone help please? I want to add sounds from my recordings which I have recorded in my mobile. Thanks!👍

27th Jun 2018, 10:22 AM
Rahul Hemdev
Rahul Hemdev - avatar
6 Respostas
+ 6
var audio = new Audio(source); audio.loop = false; audio.play();
27th Jun 2018, 10:43 AM
Toni Isotalo
Toni Isotalo - avatar
+ 6
Ok. Thanks!
27th Jun 2018, 11:30 AM
Rahul Hemdev
Rahul Hemdev - avatar
+ 6
https://code.sololearn.com/W8Yp74D9f63n/?ref=app Why isn't the music playing? Do you know the reason?
27th Jun 2018, 12:43 PM
Rahul Hemdev
Rahul Hemdev - avatar
+ 5
url = source of audio ?
27th Jun 2018, 10:55 AM
Rahul Hemdev
Rahul Hemdev - avatar
+ 5
Your source is faulty. You need to specify the url http://hosting.com/audio.mp3 Here try this https://raw.githubusercontent.com/V-Play/FlappyBird/master/assets/audio/sfx_point.wav var url = “https://raw.githubusercontent.com/V-Play/FlappyBird/master/assets/audio/sfx_point.wav”; var audio = new Audio(url); audio.loop = false; audio.play();
27th Jun 2018, 1:50 PM
Toni Isotalo
Toni Isotalo - avatar
+ 4
yes
27th Jun 2018, 11:29 AM
Toni Isotalo
Toni Isotalo - avatar