Ask coding questions

← Back to all posts
P5 Sound
ReallyBasic (13)

I am trying to implement sound in my html / js project, but it is currently not working. Without current access to a working console, I can't figure out what is wrong, or even if anything is.

If anyone knows how to play sound from an html page, I would be very grateful for your response.

Comments
hotnewtop
Coder100 (18207)

Did you forget to import the p5 sound library? It is an extension, it is not bundled with the main distro.

CodeMaster007 (108)

You can use the <embed> tag or the newer <audio> tag to insert a sound file directly into a web page. With audio files, I recommend using the . MP3 file format because of its wide acceptance on the Internet, and is utilized by all browsers and operating systems. This will run music in the background whenever the page loads.

GatewayDuckYT (60)

at this time audio can only be auto played on user interaction to the webpage this can be a click or things like this u can add $('#music').append('music html') to append on user interaction