fix folder watch #69, jump to next file when current file is deleted
This commit is contained in:
parent
7b9b654de5
commit
66234077a4
@ -26,13 +26,13 @@ from watchdog.events import PatternMatchingEventHandler
|
||||
from watchdog.observers import Observer
|
||||
|
||||
from .filters import build_filtergraph
|
||||
from .utils import MediaProbe, _storage, messenger, stdin_args
|
||||
|
||||
from .utils import MediaProbe, _current, _ff, _storage, messenger, stdin_args
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# folder watcher
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class MediaStore:
|
||||
"""
|
||||
fill media list for playing
|
||||
@ -85,8 +85,14 @@ class MediaWatcher:
|
||||
def __init__(self, media):
|
||||
self._media = media
|
||||
|
||||
print(_storage.extensions)
|
||||
|
||||
self.extensions = ['*{}'.format(ext) for ext in _storage.extensions]
|
||||
|
||||
print(self.extensions)
|
||||
|
||||
self.event_handler = PatternMatchingEventHandler(
|
||||
patterns=_storage.extensions)
|
||||
patterns=self.extensions)
|
||||
self.event_handler.on_created = self.on_created
|
||||
self.event_handler.on_moved = self.on_moved
|
||||
self.event_handler.on_deleted = self.on_deleted
|
||||
@ -121,6 +127,9 @@ class MediaWatcher:
|
||||
messenger.info(
|
||||
'Remove file from media list: "{}"'.format(event.src_path))
|
||||
|
||||
if _current.clip == event.src_path:
|
||||
_ff.decoder.terminate()
|
||||
|
||||
def stop(self):
|
||||
self.observer.stop()
|
||||
self.observer.join()
|
||||
|
@ -4,7 +4,7 @@ from threading import Thread
|
||||
|
||||
from ffplayout.folder import GetSourceFromFolder, MediaStore, MediaWatcher
|
||||
from ffplayout.playlist import GetSourceFromPlaylist
|
||||
from ffplayout.utils import (_ff, _log, _playlist, _pre, _text,
|
||||
from ffplayout.utils import (_current, _ff, _log, _playlist, _pre, _text,
|
||||
ffmpeg_stderr_reader, messenger, pre_audio_codec,
|
||||
stdin_args, terminate_processes)
|
||||
|
||||
@ -64,6 +64,7 @@ def output():
|
||||
else:
|
||||
current_file = src_cmd[3]
|
||||
|
||||
_current.clip = current_file
|
||||
messenger.info('Play: "{}"'.format(current_file))
|
||||
|
||||
with Popen([
|
||||
|
@ -6,7 +6,7 @@ from threading import Thread
|
||||
|
||||
from ffplayout.folder import GetSourceFromFolder, MediaStore, MediaWatcher
|
||||
from ffplayout.playlist import GetSourceFromPlaylist
|
||||
from ffplayout.utils import (_ff, _log, _playlist, _playout,
|
||||
from ffplayout.utils import (_current, _ff, _log, _playlist, _playout,
|
||||
ffmpeg_stderr_reader, get_date, messenger,
|
||||
stdin_args, terminate_processes)
|
||||
|
||||
@ -61,6 +61,7 @@ def output():
|
||||
else:
|
||||
current_file = src_cmd[3]
|
||||
|
||||
_current.clip = current_file
|
||||
messenger.info('Play: "{}"'.format(current_file))
|
||||
cmd = [
|
||||
'ffmpeg', '-v', _log.ff_level.lower(), '-hide_banner',
|
||||
|
@ -4,8 +4,8 @@ from threading import Thread
|
||||
|
||||
from ffplayout.folder import GetSourceFromFolder, MediaStore, MediaWatcher
|
||||
from ffplayout.playlist import GetSourceFromPlaylist
|
||||
from ffplayout.utils import (_ff, _log, _playlist, _playout, _pre, _text,
|
||||
ffmpeg_stderr_reader, get_date, messenger,
|
||||
from ffplayout.utils import (_current, _ff, _log, _playlist, _playout, _pre,
|
||||
_text, ffmpeg_stderr_reader, get_date, messenger,
|
||||
pre_audio_codec, stdin_args, terminate_processes)
|
||||
|
||||
_WINDOWS = os.name == 'nt'
|
||||
@ -72,6 +72,7 @@ def output():
|
||||
else:
|
||||
current_file = src_cmd[3]
|
||||
|
||||
_current.clip = current_file
|
||||
messenger.info('Play: "{}"'.format(current_file))
|
||||
|
||||
with Popen([
|
||||
|
@ -122,6 +122,7 @@ _playout = SimpleNamespace()
|
||||
|
||||
_init = SimpleNamespace(load=True)
|
||||
_ff = SimpleNamespace(decoder=None, encoder=None)
|
||||
_current = SimpleNamespace(clip=None)
|
||||
_global = SimpleNamespace(time_delta=0)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user