瀏覽代碼

Made song start with song it last played.

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

+ 11 - 2
app/app.js

@@ -644,8 +644,16 @@ if (Meteor.isServer) {
             // Add a global video to Playlist so it can proceed
         } else {
             var startedAt = Date.now();
-            var songs = Playlists.find({type: type}).fetch()[0].songs;
-            var currentSong = 0;
+            var playlist = Playlists.find({type: type}).fetch()[0];
+            var songs = playlist.songs;
+            if (playlist.lastSong === undefined) {
+                Playlists.update({type: type}, {$set: {lastSong: 0}});
+                playlist = Playlists.find({type: type}).fetch()[0];
+                songs = playlist.songs;
+            }
+            console.log(playlist.lastSong, type);
+            console.log(playlist.lastSong, type);
+            var currentSong = playlist.lastSong;
             addToHistory(songs[currentSong], startedAt);
 
             function addToHistory(song, startedAt) {
@@ -657,6 +665,7 @@ if (Meteor.isServer) {
                 if (currentSong < (songs.length - 1)) {
                     currentSong++;
                 } else currentSong = 0;
+                Playlists.update({type: type}, {$set: {lastSong: currentSong}});
                 songTimer();
                 addToHistory(songs[currentSong], startedAt);
             }