0
オーディオが終了したときに機能を開始しようとしています。私はこの機能を使用してサウンドを作成しています。JSオーディオはオーディオの終了時にトリガーされません
function sound(src,volume,repeat) {
volume = volume || 1
repeat = repeat || false;
this.sound = document.createElement("audio");
this.sound.volume = volume;
this.sound.src = src;
this.sound.setAttribute("preload", "");
this.sound.setAttribute("class", "gamesound");
if(repeat)this.sound.setAttribute("loop","");
this.sound.style.display = "none";
document.body.appendChild(this.sound);
this.play = function(){
this.sound.play();
}
this.stop = function(){
this.sound.pause();
}
this.pause = function(){
this.sound.pause();
}
this.onend = function (s){
this.sound.onended = s;
}
this.load = function(){
this.sound.load();
}
this.currentTime = function (t){
this.sound.currentTime = t;
}
}
だから、この
var song = new sound("sound.mp3",0.2,true);
song.ended(function(){
alert("ended");
})
ように使用することができます。しかしその私がここで間違ったつもりだところ、トリガではありません。
私はそれが何かばかげたことを知っていた参照してください。ありがとう@ Yousef – MasterT