+ 4

How To Play Audio In Javascript?

hmm... maybe i see a question like this before... but i can't find it... so i post a new question i want to make audio play when the screen is clicked

19th Aug 2018, 3:18 AM
Jingga Sona
Jingga Sona - avatar
7 ответов
+ 10
var music = new Audio(URL for audio here); document.body.onclick = function() { music.play(); };
22nd Aug 2018, 5:51 AM
Rowsej
Rowsej - avatar
+ 4
jelger.js I want to play audion in JAVASCRPT
21st Aug 2018, 6:36 AM
Jingga Sona
Jingga Sona - avatar
+ 4
Jiпбба Sоnа do you want to trigger play audio using js or you want to play audio without html audio tag
21st Aug 2018, 11:01 AM
Amir Ahmad
Amir Ahmad - avatar
+ 4
jelger.js yes, 1.createElement "audio" by js 2.set src attribute of audio tag and set value of src
21st Aug 2018, 12:51 PM
Amir Ahmad
Amir Ahmad - avatar
+ 3
Amir Ahmad i want to make audio play when we tap the screen...
22nd Aug 2018, 2:01 AM
Jingga Sona
Jingga Sona - avatar
+ 3
Rowsej thannks a lot rowsej! sorry i didnt noticed this before😅😅😅 THANKS!
1st Sep 2018, 12:09 PM
Jingga Sona
Jingga Sona - avatar
+ 2
jelger.js did you mean accesing HTML?
19th Aug 2018, 7:07 AM
Jingga Sona
Jingga Sona - avatar