I built a page where a user can input a value in seconds, and then a ping will sound at that interval. I also put together a timer, that should be in sync with the ping intervals. Like if they input 5 - the clock should be running past 5, 10, 15 ect... when the ping is sounding. For a reason I can't figure out, the sound doesn't seem to quite be sync'd with the clock and it gets worse the longer it's been running. Thanks for your help!
$(document).ready(function() {
$('#set_ping').click(function() {
interval = parseInt($('#ping_val').val()*1000,10);
$('#ping_alert').text('The ping will sound every ' + interval/1000 + ' seconds.');
});
$('#go').click(function() {
timer();
setInterval(sound, interval);
});
function sound() {
$('#audio').append('<embed src="assets/audio/sound88.mp3" autostart="true" hidden="true" loop="false">');
}
var seconds = 0;
function timer() {setInterval(function() {
$('#progress').text(seconds++/100);
}, 10);
}
});