Playing Audio during your HMTL website can really spice up your site.
π THANKS: I appreciate your claps cause it takes time to write these free articles.
0.) (Pre-req) Drag the audio file into your Code π»
Ensure you have an audio file (ex: .mp3) accesible in your code.
1.) Use this code to load and play/pause the audioπ³
let audio = new Audio('YOUR_AUDIO_FILE.mp3');// Play Audio
audio.play();// Pause Audio
audio.pause();// Reload audio from beggining
audio.load()
Go to the W3 Schools Audio Object docs for more properties/methods.
Thanks for reading! π Please leave a clap if this helped. Alsoβ¦