Help

Difference between revisions of "Embed audio in HTML"

(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...")
 
m (Yug moved page Help:Inpage to Help:How to embed audio in webpage?: better)

Revision as of 12:19, 19 May 2018

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