Kirk's UI Dev Blog
Friday, October 25, 2013
quick and dirty javascript sounds
I've written about HTML5 audio before, but the quickest/dirtiest way is:
var fx = document.createElement('audio');
fx.setAttribute('src', 'soundfile.mp3');
fx.setAttribute('loop', 'loop'); //optional
//...
fx.play();
//...
fx.pause();
non-looping and resetting variants are left as an exercise for the reader.
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment