Help
Difference between revisions of "Embed audio in HTML"
Line 22: | Line 22: | ||
<source src="/to/folder/Bazinga.ogg" type="audio/ogg"> | <source src="/to/folder/Bazinga.ogg" type="audio/ogg"> | ||
<source src="/to/folder/Bazinga.mp3" type="audio/mpeg"><!-- fallback --> | <source src="/to/folder/Bazinga.mp3" type="audio/mpeg"><!-- fallback --> | ||
− | Your | + | Your browser does not support HTML5 audio. Please download and install a modern browser. |
</audio> | </audio> | ||
</pre> | </pre> | ||
+ | |||
;References | ;References | ||
+ | * https://www.w3schools.com/html/html5_audio.asp |
Revision as of 12:37, 19 May 2018
Given an audio file Bazinga.mp3
.
Using Howler JS
- 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
Using HTML5 audio
<audio controls="controls"> <source src="/to/folder/Bazinga.ogg" type="audio/ogg"> <source src="/to/folder/Bazinga.mp3" type="audio/mpeg"><!-- fallback --> Your browser does not support HTML5 audio. Please download and install a modern browser. </audio>
- References