我有下一个代码,但我无法调用 ShowMedalMessage() 函数
var totalsounds = 3;
var currentsound = 1;
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'notify.wav');
audioElement.setAttribute('autoplay', 'autoplay');
audioElement.addEventListener('ended', function() {
if (currentsound < totalsounds) {
this.currentTime = 0;
this.play();
currentsound = currentsound + 1;
}
ShowMedalMessage(1);
}, false);
如果对函数的调用在 audioElement.addEventListener 之前,它会正确调用,但如果 ShowMedalMessage(1); 行 在里面,它不起作用:(
谢谢!