Skip to content

Commit a8e7319

Browse files
committed
Update player.js
1 parent a45b02b commit a8e7319

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

assets/js/player.js

+9
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,29 @@ function playSoura(data) {
3939
const selectedSoura = data[souraIndex];
4040

4141
if (selectedSoura) {
42+
43+
// Set the audio source
4244
audioPlayer.src = selectedSoura.url;
4345
audioPlayer.load();
4446

47+
// Set the title attribute of the audio element
48+
audioPlayer.setAttribute('title', selectedSoura.name);
49+
4550
const savedTime = localStorage.getItem(`audioTime_${selectedSoura.url}`);
4651
audioPlayer.currentTime = savedTime ? parseFloat(savedTime) : 0;
4752

53+
// Set the text of the soura title element
4854
souraTitle.textContent = `الان: ${selectedSoura.name}`;
4955

56+
// Play the audio
5057
audioPlayer.play();
5158

59+
// Save the current time of the audio during playback
5260
audioPlayer.addEventListener('timeupdate', () => {
5361
localStorage.setItem(`audioTime_${selectedSoura.url}`, audioPlayer.currentTime);
5462
});
5563

64+
// Play the next soura once the current one ends
5665
audioPlayer.onended = () => {
5766
currentIndex = (currentIndex + 1) % 3;
5867
playCurrentSoura();

0 commit comments

Comments
 (0)