I'm looking for a jquery countdown clock or a timer to start with sound play when a date has been setup. I found a lot sites have exapmles of jquery countdown, but no sound play with it when started counting...
how can I add sound to a Jquery countdown timer??
Thanks
Update: this is a demo of mootool timer http://jsfiddle.net/QH6X8/185/
that I want to use a sound play with! any idea how to do that?
the html code:
<div id="countdown"></div>
And the mootool code is;
var end = new Date('16 May 2013 13:29:00'); // set expiry date and time..
var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour *24
var timer;
function showRemaining()
{
var now = new Date();
var distance = end - now;
if (distance < 0 ) {
// handle expiry here..
clearInterval( timer ); // stop the timer from continuing ..
alert('Expired'); // alert a message that the timer has expired..
return; // break out of the function so that we do not update the counters with negative values..
}
var days = Math.floor(distance / _day);
var hours = Math.floor( (distance % _day ) / _hour );
var minutes = Math.floor( (distance % _hour) / _minute );
var seconds = Math.floor( (distance % _minute) / _second );
var milliseconds = Math.floor( (distance % _second) );
document.getElementById('countdown').innerHTML = 'Days: ' + days + '<br />';
document.getElementById('countdown').innerHTML += 'Hours: ' + hours+ '<br />';
document.getElementById('countdown').innerHTML += 'Minutes: ' + minutes+ '<br />';
document.getElementById('countdown').innerHTML += 'Seconds: ' + seconds+ '<br />';
document.getElementById('countdown').innerHTML += 'Milliseconds: ' + milliseconds+ '<br />';
}
timer = setInterval(showRemaining, 1);
The best bet is to use an audio plugin solution.
One of the best is howler.js.