I need to check how long someone played the mp3 file, I read about the .buffored function, which allows you to check how many times where or when it was stopped, but you have some option to count the listening time of mp3
const myAudio = document.getElementById('my-audio');
const bufferedTimeRanges = myAudio.buffered;
<audio id="my-audio" controls src="music.mp3">
</audio>
const audio = document.querySelector('audio');
audio.ontimeupdate = (event) => {
console.log('The currentTime attribute has been updated. Again.');
};
you can use the ontimeupdate event to receive currentTime information about the audio file. You can combine it with the onended event to count how many times the user ended the audio and you'll have the whole feature done.