change shuffle mode
This commit is contained in:
parent
9fb086a1fd
commit
e390142293
48
ffplayout.py
48
ffplayout.py
@ -1231,7 +1231,10 @@ class MediaStore:
|
|||||||
glob.glob(os.path.join(self.folder, '**', ext),
|
glob.glob(os.path.join(self.folder, '**', ext),
|
||||||
recursive=True))
|
recursive=True))
|
||||||
|
|
||||||
self.sort()
|
if _storage.shuffle:
|
||||||
|
self.rand()
|
||||||
|
else:
|
||||||
|
self.sort()
|
||||||
|
|
||||||
def add(self, file):
|
def add(self, file):
|
||||||
self.store.append(file)
|
self.store.append(file)
|
||||||
@ -1245,6 +1248,10 @@ class MediaStore:
|
|||||||
# sort list for sorted playing
|
# sort list for sorted playing
|
||||||
self.store = sorted(self.store)
|
self.store = sorted(self.store)
|
||||||
|
|
||||||
|
def rand(self):
|
||||||
|
# random sort list for playing
|
||||||
|
random.shuffle(self.store)
|
||||||
|
|
||||||
|
|
||||||
class MediaWatcher:
|
class MediaWatcher:
|
||||||
"""
|
"""
|
||||||
@ -1309,36 +1316,19 @@ class GetSourceFromFolder:
|
|||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
while True:
|
while True:
|
||||||
if _storage.shuffle:
|
while self.index < len(self._media.store):
|
||||||
clip = random.choice(self._media.store)
|
self.probe.load(self._media.store[self.index])
|
||||||
|
filtergraph = build_filtergraph(
|
||||||
if len(self.last_played) > len(self._media.store) / 2:
|
float(self.probe.format['duration']), 0.0,
|
||||||
self.last_played.pop(0)
|
float(self.probe.format['duration']), False, False,
|
||||||
|
False, self.probe)
|
||||||
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
|
|
||||||
|
|
||||||
|
yield [
|
||||||
|
'-i', self._media.store[self.index]
|
||||||
|
] + filtergraph
|
||||||
|
self.index += 1
|
||||||
else:
|
else:
|
||||||
while self.index < len(self._media.store):
|
self.index = 0
|
||||||
self.probe.load(self._media.store[self.index])
|
|
||||||
filtergraph = build_filtergraph(
|
|
||||||
float(self.probe.format['duration']), 0.0,
|
|
||||||
float(self.probe.format['duration']), False, False,
|
|
||||||
False, self.probe)
|
|
||||||
|
|
||||||
yield [
|
|
||||||
'-i', self._media.store[self.index]
|
|
||||||
] + filtergraph
|
|
||||||
self.index += 1
|
|
||||||
else:
|
|
||||||
self.index = 0
|
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user