1<script>
2function play() {
3 var audio = new Audio('https://interactive-examples.mdn.mozilla.net/media/examples/t-rex-roar.mp3');
4 audio.play();
5}
6</script>
7<button onclick-"play();">PLAY MY AUDIO</button>
1let myAudioElement = new Audio('audio.mp3');
2myAudioElement.addEventListener("canplaythrough", event => {
3 /* the audio is now playable; play it if permissions allow */
4 myAudioElement.play();
5});