This is what i have. My problem is, each loop doesn't wait setTimeout to complete its job. I have 2 console.log('elmDuration = ')... before slider.goToNextSlide executed. Which is wrong. I would use generator functions and yield if this is a server side code, but not.
$('li').each(function(index, elm){
var image = $(elm).find('img')[0];
var video = $(elm).find('video')[0];
var media = image || video;
var elmDuration = $(media).attr('data-duration');
console.log("elmDuration = ", elmDuration);
(function(){
setTimeout(slider.goToNextSlide, elmDuration * 1000);
})();
});
I am stuck with this. Thanks.