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);
}
My code in index.ts includes a function called handleAudioPlayer with two arguments. When the audio is playing, an event listener is added. And when it's paused, the event listener should be removed. However, I am encountering an issue where the event listeners are getting duplicated, which is causing some problems. Any assistance on how to resolve this would be greatly appreciated!