I have Audio file playing in jQuery. sometimes when the download speed is slower than the playing speed, audio can stop. I want to get a notification when this situation is happening and so for example the music stops and I get the console error every minute, then once the buffer is loaded enough to play the song then it stops sending the notification. In reality there will be a loading icon that appears and disapears. So i need both inititing event and stopping event.
This is the events I tried to have but I do not get the right results.
the list of events are here: link
$(audio).on("canplay, playing, ", function () {
console.log("stop Buffering");
});
$(audio).on("buffered", function () {
console.log("buffering");
})
buffered
is a property of audio element, not an event. You should be listening to waiting
event.
The waiting event occurs when the video stops because it needs to buffer the next frame. This event can also be used on elements, but it is mostly used for videos.