瀏覽代碼

Changed way current song index is handled.

KrisVos130 9 年之前
父節點
當前提交
211cb8c381
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      app/app.js

+ 8 - 0
app/app.js

@@ -909,6 +909,7 @@ if (Meteor.isServer) {
             songs = playlist.songs;
         }
         var currentSong = playlist.lastSong;
+        var currentTitle = songs[currentSong].title;
         addToHistory(songs[currentSong], startedAt);
 
         function addToHistory(song, startedAt) {
@@ -917,9 +918,16 @@ if (Meteor.isServer) {
 
         function skipSong() {
             songs = Playlists.find({type: type}).fetch()[0].songs;
+            song.forEach(function(song, index) {
+                if (song.title === currentTitle) {
+                    currentSong = index;
+                }
+            });
             if (currentSong < (songs.length - 1)) {
                 currentSong++;
             } else currentSong = 0;
+            if (songs)
+            currentTitle = songs[currentSong].title;
             Playlists.update({type: type}, {$set: {lastSong: currentSong}});
             songTimer();
             addToHistory(songs[currentSong], startedAt);