fix reshuffle problem

This commit is contained in:
Terry Geng 2020-02-05 17:52:12 +08:00
parent 56036d8736
commit dce85aefe7

View File

@ -1,5 +1,6 @@
import youtube_dl
import variables as var
import random
class PlayList:
playlist = []
@ -79,7 +80,14 @@ class PlayList:
return self.playlist[index]
def randomize(self):
# current_index will lose track after shuffling, thus we take current music out before shuffling
current = self.current_item()
del self.playlist[self.current_index]
random.shuffle(self.playlist)
self.playlist.insert(0, current)
self.current_index = 0
self.version += 1
def clear(self):