我想在每一个功能的做函数调用回退与.play()
由1连续HTML5音频.play(),只有第1次触发
最有趣的播放声音1播放连续的声音序列是: 每次在iPad设备上播放时都会有不同的声音表现。 * 有时播放音频3次,有时4次,甚至只有1次! *
只有iPad中的“突然停止问题”,在我的谷歌浏览器上没问题。
它不是iPad上的自动播放的问题,我想怎么我已经在第一时间触发...
请看看,并有一个测试的iPad也许并请帮助...
的Html - 身体:
<audio id="html5soundtag">
<source src="1.mp3" type="audio/mpeg">
</audio>
<a href="javascript://" onClick="playhtml5sound1('1.mp3')">aaaa</a>
的Javascript:
var audioPath ="";
var audioElement = document.getElementById('html5soundtag');
function playhtml5sound1(filename){
audioPath = filename;
audioElement.src = audioPath;
audioElement.src = audioPath
audioElement.load()
audioElement.play();
audioElement.addEventListener("ended",soundcallback1);
};
var soundcallback1 = function(){
alert("1st");
audioElement.removeEventListener("ended",soundcallback1);
playhtml5sound2("1.mp3");
}
function playhtml5sound2(filename){
audioPath = filename;
audioElement.src = audioPath;
audioElement.src = audioPath
audioElement.load();
audioElement.play();
audioElement.addEventListener("ended",soundcallback2);
};
var soundcallback2 = function(){
alert("2nd");
audioElement.removeEventListener("ended",soundcallback2);
playhtml5sound3("1.mp3");
}
function playhtml5sound3(filename){
audioPath = filename;
audioElement.src = audioPath;
audioElement.src = audioPath
audioElement.load();
audioElement.play();
audioElement.addEventListener("ended",soundcallback3);
};var soundcallback3 = function(){
alert("3rd");
audioElement.removeEventListener("ended",soundcallback3);
playhtml5sound4("1.mp3");
}
function playhtml5sound4(filename){
audioPath = filename;
audioElement.src = audioPath;
audioElement.src = audioPath
audioElement.load();
audioElement.play();
audioElement.addEventListener("ended",soundcallback4);
};var soundcallback4 = function(){
alert("4th");
audioElement.removeEventListener("ended",soundcallback4);
playhtml5sound5("1.mp3");
}
function playhtml5sound5(filename){
audioPath = filename;
audioElement.src = audioPath;
audioElement.src = audioPath
audioElement.load();
audioElement.play();
audioElement.addEventListener("ended",soundcallback5);
};var soundcallback5 = function(){
alert("5th");
audioElement.removeEventListener("ended",soundcallback5);
playhtml5sound6("1.mp3");
}
function playhtml5sound6(filename){
alert("This is End. " + filename);
}
你使用1.MP3只?有6种不同的回调?你打算玩1.mp3,2.mp3等? –
是的,对于测试,我只使用单个样品声音“1.mp3”,因为现在我的问题是回调将突然死亡(停止)在iPad上运行时...和每次不同的时间“死” !例如,将只有2次回调运行,下次运行完毕,然后下一次运行1次回调...刷新网页后仅有不同... – user1900121
请[DRY](http: //en.wikipedia.org/wiki/Don't_repeat_yourself) 绝对没有必要有5个非常相同的功能,更不用说事件监听器杂耍了。 – Cerbrus