我有一些按钮,可以在按下时播放音频。这些的ID是设置音频src的原因。我有一个按钮,可以在队列模式(打开或关闭)之间进行切换,我想让它在第一个之后可以播放声音的位置,并继续向队列添加声音。 这是我的按钮音频的js:
string(310) "{"totalPages":0,"firstPage":true,"lastPage":true,"numberOfElements":0,"number":0,"totalElements":0,"columns":{"columnIds":["metrics/visits:::0","metrics/visitors:::2","metrics/timespentvisit:::4"]},"summaryData":{"totals":[2740.0,1384.0,241.4753313696613]},"oberonRequestXML":[null],"oberonResponseXML":[null]}"
按钮的HTML:
var audios = Array.prototype.map.call(document.getElementsByClassName("myButton")
, function (el) {
var audio = new Audio();
var src = "mp3/" + el.id + ".mp3";
el.onclick = function () {
audios.forEach(audio => audio.pause()); /*comment these three lines out to disable stopping previously played audio*/
audios.forEach(audio => audio.currentTime = 0.0); /*this too*/
audios.forEach(audio => audio.src = ""); /*this too*/
audio.src = src;
audio.play();
console.log("Now Playing " + el.id);
console.log(decodeURI(src));
};
return audio;
});
我不确定如何使其添加下一个要播放的声音