First off here is my javascript code:
$(function() {
stepFade('.fadable',700,1);
});
function stepFade(target, speed, opacity) {
var mysound = new Audio("./sounds/kick.mp3");
var $fade = $(target);
($fade).each( function( i ) {
$(this).delay(i*speed).fadeTo(speed, opacity);
mysound.play();
mysound.currentTime = 0;
});
}
My goal here is to play a sound in conjunction with the fade ins that are happening on the website with jquery. I'm having trouble looping the sound in a way so that they are in sync. I've tried resetting the currentTime and that doesn't seem to work for some reason.
Another method would be to use mysound.loop(); however this just plays the sound in a loop without any considerations in the timing of the sounds. Thus this becomes de-synchronized with the animations.
Anyone can first explain why setting the current time doesn't work and what possible solutions exists?
Thanks!