change shuffle mode

This commit is contained in:
Jonathan Baecker 2019-12-02 09:55:42 +01:00
parent 9fb086a1fd
commit e390142293

View File

@ -1231,6 +1231,9 @@ class MediaStore:
glob.glob(os.path.join(self.folder, '**', ext),
recursive=True))
if _storage.shuffle:
self.rand()
else:
self.sort()
def add(self, file):
@ -1245,6 +1248,10 @@ class MediaStore:
# sort list for sorted playing
self.store = sorted(self.store)
def rand(self):
# random sort list for playing
random.shuffle(self.store)
class MediaWatcher:
"""
@ -1309,23 +1316,6 @@ class GetSourceFromFolder:
def next(self):
while True:
if _storage.shuffle:
clip = random.choice(self._media.store)
if len(self.last_played) > len(self._media.store) / 2:
self.last_played.pop(0)
if clip not in self.last_played:
self.last_played.append(clip)
self.probe.load(clip)
filtergraph = build_filtergraph(
float(self.probe.format['duration']), 0.0,
float(self.probe.format['duration']), False, False,
False, self.probe)
yield ['-i', clip] + filtergraph
else:
while self.index < len(self._media.store):
self.probe.load(self._media.store[self.index])
filtergraph = build_filtergraph(