Text Link To Play Audio On Click

Hi guys,

Looking for a simple solution for a landing page build-out. I have my background video in and would like separately for the user to be able to click on a text link that will play audio once it is clicked. any suggestions?


hi @Mattestudiosnyc if you mean separate audio you can use custom code

<button onclick="playSound()">Play</button>

let playSound = () => new Audio("http://codeskulptor-demos.commondatastorage.googleapis.com/GalaxyInvaders/theme_01.mp3)").play();

I’m not sure if I am inputting the code wrong or what but it is not working.

hi @Mattestudiosnyc i have made another example in CodePen. it is different approach (ternary operator) I made in few minutes so it can be improved as it is only play-pause and you can add another functionality. :slight_smile: