Help

Embed audio in HTML

Revision as of 09:33, 19 May 2018 by Yug (talk | contribs) (Created page with "=== Minimal === Given an audio file Bazinga.mp3. '''HTML:''' <pre><script src="./howler-2.0.8.js"></script> <buton id="bazingaId" class=&q...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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