Reputation: 466
I am trying to bind an event where when the audio finished playing, it would fire a certain function, but however, when I bind the event it says aux.bind is not a function.
var aux = new Audio("file.mp3");
aux.bind("ended", function(e){
aux.volume = 1.0;
});
I have even tried aux.on(...)
and it does not work either.
UPDATE: I will require to unbind the event later after the "ended" has fired
Upvotes: 0
Views: 977
Reputation: 373
Use the onended() event from the Audio object. Eg.
var aux = new Audio("file.mp3");
aud.play();
aud.onended = function() {
alert("The audio has ended");
};
Upvotes: 1