Create a direct web link to a sound file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Create a direct web link to a sound file

I want to add music to a JavaScript game that I'm developing. My other question about creating a direct link to an image file was answered perfectly by Domagoj Puljic with the suggestion of the site postimg.org. If anyone knows a similar site that can allow me to create a direct web link to a sound file, that would be perfect for adding music to my game.

18th Jul 2017, 1:13 AM
Noah Wise
Noah Wise - avatar
1 Answer
+ 1
if you download ans save the sound file you could put it in a directory Sounds local to the project. then in a js file, assuming that sound file is somewhere on the webpage (text "playMe.mp3") get this text by id or element or even jQuery then access it in the directory with some sort of play functionality. a few months ago I was developing an application that allowed the users to select words in spanish and teach it to them, either english to spanish or a picture or sound. I used js for my sound bit. I would Highly recommend looking up p5.js they have built in functions for EVERYTHING including playing an audio track. hope this helps
18th Jul 2017, 4:08 AM
Michael Szczepanski
Michael Szczepanski - avatar