我有一个代码,我不能叫ShowMedalMessage()函数呼叫从使用addEventListener()
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);就在里面,它不工作:(
谢谢!
你检查控制台日志在Chrome/Firefox的错误?我没有看到任何错误的代码。 –
它可能不会在事件发生时启动,它会记录一些错误? –
我看,在Firefox不工作的音频播放...与o r没有ShowMedalMessage()...怪异的:/ – MGE