I'm working with a default
audio
onended
loop
I seperated my previous attempt into an answer to remove the question from the unanswered queue, but it originally was included here
At this point, the only solution I see is to check the duration of the track ahead of time, then set the following timeout:
$('audio').bind('loadedmetadata', function() {
duration = $(this).prop('duration') * 1000; // get duration in milliseconds
var fadetimer = setTimeout(function(){
// set up next audio file
}, duration - 5000); // execute timeout 5 seconds before end of playback
});
This seems vastly inefficient to me, however. I am also unsure whether this method will leave "garbage" timeouts or event bindings running in the background, which will eventually add up and slow down the application.