File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -39,20 +39,29 @@ function playSoura(data) {
39
39
const selectedSoura = data [ souraIndex ] ;
40
40
41
41
if ( selectedSoura ) {
42
+
43
+ // Set the audio source
42
44
audioPlayer . src = selectedSoura . url ;
43
45
audioPlayer . load ( ) ;
44
46
47
+ // Set the title attribute of the audio element
48
+ audioPlayer . setAttribute ( 'title' , selectedSoura . name ) ;
49
+
45
50
const savedTime = localStorage . getItem ( `audioTime_${ selectedSoura . url } ` ) ;
46
51
audioPlayer . currentTime = savedTime ? parseFloat ( savedTime ) : 0 ;
47
52
53
+ // Set the text of the soura title element
48
54
souraTitle . textContent = `الان: ${ selectedSoura . name } ` ;
49
55
56
+ // Play the audio
50
57
audioPlayer . play ( ) ;
51
58
59
+ // Save the current time of the audio during playback
52
60
audioPlayer . addEventListener ( 'timeupdate' , ( ) => {
53
61
localStorage . setItem ( `audioTime_${ selectedSoura . url } ` , audioPlayer . currentTime ) ;
54
62
} ) ;
55
63
64
+ // Play the next soura once the current one ends
56
65
audioPlayer . onended = ( ) => {
57
66
currentIndex = ( currentIndex + 1 ) % 3 ;
58
67
playCurrentSoura ( ) ;
You can’t perform that action at this time.
0 commit comments