使用< audio>时,.play()之后是否可以使用jquery回调? [英] Is a jquery callback available after .play() when using <audio>?
本文介绍了使用< audio>时,.play()之后是否可以使用jquery回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请问我要先播放mp3文件然后再播放另一个文件吗?
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( function () {
$('#file2)[0].play();
});
播放音频时可以使用回调吗?
Can you use callbacks when playing audio?
推荐答案
您并不是在以jQuery方法开头.
You are not calling a jQuery method to begin with.
您可以将事件处理程序附加到"onended"
事件:
You could attach an event handler to the "onended"
event:
var file = $("#file1");
file.on( "ended", function(){
$("#file2")[0].play();
});
file[0].play();
这篇关于使用< audio>时,.play()之后是否可以使用jquery回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文