Преглед изворни кода

Fix repeat-one navigation in Musicify

Update track navigation logic so `repeat: 'one'` behaves like looped playback at queue boundaries. `nextTrack()` now wraps to the first item when reaching the end under repeat-one, and `prevTrack()` wraps to the last item (and stops playback when repeat is off at the start). This also removes the previous "restart track if >3s" behavior so previous-track consistently follows queue navigation rules.
Toby Chui пре 1 месец
родитељ
комит
870c6803b5
1 измењених фајлова са 8 додато и 3 уклоњено
  1. 8 3
      src/web/Musicify/musicify.js

+ 8 - 3
src/web/Musicify/musicify.js

@@ -1056,7 +1056,7 @@ function musicifyApp() {
             if (eq.length === 0) return;
             var next = ei + 1;
             if (next >= eq.length) {
-                if (this.repeat === 'all') next = 0;
+                if (this.repeat === 'all' || this.repeat === 'one') next = 0;
                 else { this._audio.pause(); this.isPlaying = false; return; }
             }
             // Map back to queue index for shuffle mode
@@ -1072,11 +1072,16 @@ function musicifyApp() {
         },
 
         prevTrack() {
-            if (this.currentTime > 3) { this._audio.currentTime = 0; return; }
             var eq = this._effectiveQueue();
             var ei = this._effectiveIndex(this.queueIndex);
             var prev = ei - 1;
-            if (prev < 0) { prev = this.repeat === 'all' ? eq.length - 1 : 0; }
+            if (prev < 0) { 
+                 if (this.repeat === 'all' || this.repeat === 'one'){
+                    prev = eq.length - 1; 
+                 }else{
+                    this._audio.pause(); this.isPlaying = false; return;
+                 }
+            }
             if (this.shuffle) {
                 var prevSong = this.shuffledQueue[prev];
                 for (var i = 0; i < this.queue.length; i++) {