该代码段一直在工作,并且不停地重复播放音频文件,尝试了诸如for循环的许多操作,但是根据.reverse()
函数,它要么播放第一个音频文件,要么播放最后一个音频文件
var token = writtenNumber(21, { lang: 'ar' }).split(' ');
var playlist = new Array();
for (var i = 0; i < token.length; i++) {
playlist.push(token[i] + '.ogg')
}
console.log(playlist);
function callCustomer() {
customerNumber.play();
customerNumber.onended = function() {
var audio = new Audio(),
i = 0;
audio.addEventListener('ended', function() {
i = ++i < playlist.length ? i : 0;
console.log(i)
audio.src = token[i] + '.ogg';
audio.play();
audio.loop = false;
}, true);
audio.volume = 0.3;
audio.loop = false;
audio.src = token[0] + '.ogg';
audio.play();
}
}