I'm using JS Audio
class to play a file:
var audio = new Audio('hello.mp3');
audio.play();
Is there a way to use an event to detect the file play has ended?
I'm using JS Audio
class to play a file:
var audio = new Audio('hello.mp3');
audio.play();
Is there a way to use an event to detect the file play has ended?
Try this:
var audio = new Audio('hello.mp3');
audio.play();
audio.onended = function() {
console.log("The audio has ended");
};
Here is the doc