参考MediaElement.js。如果某个特定音频文件已经结束,如何触发事件(调用函数)?
var myAudioFiles = ['audioFile1.wav', 'audioFile2.wav', 'audioFile3.wav'];
var myPlayer = new MediaElementPlayer('#myPlayer');
myPlayer.setSrc(myAudioFiles[0]);
myPlayer.play();
伪代码:
if (hasEnded(myAudioFiles[0])) {
doSomething();
}
答案 0 :(得分:2)
请试一试。
$(function(){
$('audio,video').mediaelementplayer({
success: function(player, node) {
player.addEventListener('ended', function(e){
player.src = 'media/somefile.mp4';
player.load();
player.play();
});
}
});
});
从这里复制:
mediaelement.js - play another video at end of 1st video