Help

Embed audio in HTML

Revision as of 12:19, 19 May 2018 by Yug (talk | contribs) (Yug moved page Help:Inpage to Help:How to embed audio in webpage?: better)

Minimal

Given an audio file Bazinga.mp3.

HTML:

<script src="./howler-2.0.8.js"></script>
<buton id="bazingaId" class="audio">Bazinga</button>

Javascript:

$('.audio').on('click', function() {  
  var sound = new Howl({ src: [ '/to/folder/Bazinga.mp3','/to/folder/Bazinga.ogg' ]});
  sound.play();
});

References