Load, Play, and Pause Audio or Songs in your HTML website 🎵
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
Go to the W3 Schools Audio Object docs for more properties/methods.
Thanks for reading! 👏 Please leave a clap if this helped. Also…
⚠️ 💻 IMPORTANT: If you’re building a website, it’s important you also think about:
1. 🎥 Embedding a Youtube video into your website
Embedding a Youtube video into your website HTML (+Looping +AutoPlay)🎥
The Frontend world is moving more and more to dynamic content including animations and videos.
2. 👥 Adding a thumbnail for sharing on social media:
How to add a website thumbnail for sharing your HTML site on social media (Facebook, LinkedIn …
👏 THANKS: I appreciate the claps readers give because it takes me some time to write these free articles.
3. ✅ Free resources for images, icons, and more on your website
The secret of making a startup landing page for free in 2 hours (for Santander Summer Accelerator)