index.ts
if(audio.paused) {
audio.play()
audio.addEventListener('timeupdate', (e) => handleAudioPlayer(<HTMLAudioElement>e.target,
<HTMLDivElement>audio.parentElement), true);
}
else {
audio.pause()
audio.removeEventListener('timeupdate', () => handleAudioPlayer, true);
}
Basically I have a handleAudioPlayer function that takes 2 arguments, when the audio is playing the event listener is added, and when its paused it should get removed, but here the eventListeners are getting duplicated which is bad, any help is appreciated!