riddhiman commited on
Commit
0dc1f69
·
verified ·
1 Parent(s): f0f023f

Update public/script.js

Browse files
Files changed (1) hide show
  1. public/script.js +12 -13
public/script.js CHANGED
@@ -232,19 +232,18 @@ function playMusic(fileName) {
232
  };
233
 
234
  // Updated onended event handler within playMusic function
235
- audio.onended = () => {
236
- if (isLooping) {
237
- // Replay the current song
238
- audio.currentTime = 0; // Reset the playback position to the start
239
- audio.play(); // Start playback from the beginning
240
- } else {
241
- // Your existing logic to move to the next song
242
- const currentIndex = trackList.indexOf(currentPlaying);
243
- if (currentIndex !== -1 && currentIndex < trackList.length - 1) {
244
- playMusic(trackList[currentIndex + 1]);
245
- }
246
- }
247
- };
248
 
249
  audio.onerror = () => {
250
  isLoadingMusic = false;
 
232
  };
233
 
234
  // Updated onended event handler within playMusic function
235
+ audio.onended = () => {
236
+ if (isLooping) {
237
+ // Replay the current song
238
+ audio.currentTime = 0;
239
+ audio.play();
240
+ } else {
241
+ const currentIndex = trackList.indexOf(currentPlaying);
242
+ if (currentIndex !== -1 && currentIndex < trackList.length - 1) {
243
+ playMusic(trackList[currentIndex + 1]);
244
+ }
245
+ }
246
+ };
 
247
 
248
  audio.onerror = () => {
249
  isLoadingMusic = false;