2012-08-26 45 views

回答

3
first.addEventListener('ended', function(){ 
    second.play(); 
}); 
first.play(); 
+0

但是,如果我想连续播放许多文件,我会在看回调地狱。任何方式来介绍.then()承诺像语法? – whamsicore

0

我会推荐一种东西:

// if using jQuery: 
var audios = $('audio'); 

audios.each(function(idx){ 
    $(this).bind('ended', function(){ 
     var next = audios.get(idx+1); 
     if(next){ 
      next.get(0).play(); 
     } 
    }); 
});