Is a jquery callback available after .play() when using <audio>?

前端 未结 4 1357
死守一世寂寞
死守一世寂寞 2020-12-20 03:49

Guys how do I play an mp3 file and then another once the first has finished?

I have tried the following without success..

$(\'#file1)[0].play( functi         


        
4条回答
  •  庸人自扰
    2020-12-20 04:13

    You are not calling a jQuery method to begin with.

    You could attach an event handler to the "onended" event:

    var file = $("#file1");
    
    file.on( "ended", function(){
        $("#file2")[0].play();
    });
    
    file[0].play();
    

提交回复
热议问题