diff --git a/assets/js/player.js b/assets/js/player.js index 1c876fb..33b8708 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -33,7 +33,6 @@ function playSoura(data) { const audioPlayer = document.getElementById('audioPlayer'); const souraTitle = document.getElementById('souraTitle'); let currentIndex = 0; - let timeUpdateListener = null; const playCurrentSoura = () => { const souraIndex = (startIndex + currentIndex) % data.length; @@ -57,15 +56,10 @@ function playSoura(data) { // Play the audio audioPlayer.play(); - // Remove any previous 'timeupdate' listener before adding a new one - if (timeUpdateListener) { - audioPlayer.removeEventListener('timeupdate', timeUpdateListener); - } - - // Define the new 'timeupdate' listener for the current soura - timeUpdateListener = () => { + // Save the current time of the audio during playback + audioPlayer.addEventListener('timeupdate', () => { localStorage.setItem(`audioTime_${selectedSoura.url}`, audioPlayer.currentTime); - }; + }); // Attach the 'timeupdate' listener for the current soura audioPlayer.addEventListener('timeupdate', timeUpdateListener);