我能够绑定到audio
对象的ended
事件但肯定还有更多的逻辑需要补充。这对我有用:
(function($){
var customAudio = {
initialize: function() {
var self = this;
// execute logic independently for each playlist in the document
$(\'.wp-playlist\').each(function(index) {
// determine the last track in the playlist so that
// when the last track ends we can pause the audio object
lastTrack = $(this).find(\'.wp-playlist-tracks .wp-playlist-item:last a\');
// bind to the audio object\'s ended event and execute
// our own ended logic
$(this).find(\'audio\').on(\'ended\', function() {
// pass the audio object and the last track
self.ended(this, lastTrack);
});
});
},
ended : function (audio, lastTrack) {
// if this audio element is the last track, pause it
if ( audio.currentSrc === lastTrack.attr(\'href\') ) {
audio.pause();
}
}
};
$(function() {
customAudio.initialize();
});
}(jQuery));