javascript - jQuery audio fade in and out on pause / mute -
javascript - jQuery audio fade in and out on pause / mute -
i have looked @ few similar issues can't seem work. i'm not advanced jquery i'm trying learn. think solution animate volume? here code have anyway.
html:
<div id="forest" class="sound"> <a class="center"> <img class="icon" src="images/sounds/tree.png" title="forest" /> <h4>forest</h4> </a> </div>
jquery:
$(document).ready(function() { var audioelement = document.createelement('audio'); audioelement.setattribute('src', 'audio/sounds/forest.mp3'); audioelement.setattribute('autoplay', 'autoplay'); //audioelement.load() $.get(); audioelement.addeventlistener("load", function() { audioelement.play(); }, true); $('#forest').click(function() { if (audioelement.paused) { audioelement.play(); } else { audioelement.pause(); } $(this).toggleclass('pause'); }); });
so have forest sounds play on load, thats great, , when click on #forest
pauses , plays it, fantastic. bit more class , professionalism if fade in , out on pause , resume?
any advice appreciated, time.
javascript jquery audio jquery-animate
Comments
Post a Comment