black / pause, no lights

This commit is contained in:
j 2017-10-27 22:47:45 +02:00
parent fdba57d988
commit 569dd9a06d
3 changed files with 32 additions and 12 deletions

View file

@ -12,11 +12,13 @@ import logging
logger = logging.getLogger('cdosea') logger = logging.getLogger('cdosea')
player = None player = None
quit = False
def q_binding(*args): def q_binding(*args):
global player global player
player.quit() player.quit()
del player del player
quit = True
def main(): def main():
@ -56,9 +58,21 @@ def main():
if not shift: if not shift:
player.pause = True player.pause = True
pause_next = False
play_lights = True
while True: while True:
if config.lights and player.path: if not quit and pause_next:
player.pause = True
pause_next = False
play_lights = False
elif not quit and player.path.decode().endswith('black.mp4'):
pause_next = True
play_lights = False
if play_lights and config.lights and player.path:
trigger_lights(player.path.decode()) trigger_lights(player.path.decode())
play_lights = True
try: try:
player.wait_for_playback() player.wait_for_playback()
except: except:

View file

@ -24,6 +24,12 @@ PORT = 8080
DEBUG = False DEBUG = False
def load_srt(srt):
if os.path.exists(srt):
return ox.srt.load(srt)
return []
class Subtitles(): class Subtitles():
path = None path = None
next_path = None next_path = None
@ -85,16 +91,11 @@ class Subtitles():
self.next_path = self.playlist[index] self.next_path = self.playlist[index]
def load_subtitles(self): def load_subtitles(self):
if 'png' in self.path:
self.current = []
else:
srt = self.path.replace('.mp4', '.srt') srt = self.path.replace('.mp4', '.srt')
self.current = ox.srt.load(srt) self.current = load_srt(srt)
if 'png' in self.next_path:
self.next = []
else:
srt = self.next_path.replace('.mp4', '.srt') srt = self.next_path.replace('.mp4', '.srt')
self.next = ox.srt.load(srt) self.next = load_srt(srt)
def trigger(self, data): def trigger(self, data):
logger.debug('trigger %s', data) logger.debug('trigger %s', data)
@ -112,7 +113,6 @@ class Subtitles():
data['subtitles'][os.path.basename(self.next_path)] = self.next data['subtitles'][os.path.basename(self.next_path)] = self.next
return data return data
class Socket(WebSocketHandler): class Socket(WebSocketHandler):
def initialize(self, sub): def initialize(self, sub):

View file

@ -44,6 +44,7 @@ def update_playlist(playlist, prefix, position=None, shift=True):
if not shift: if not shift:
files.append(os.path.join(STATIC_ROOT, 'title.png')) files.append(os.path.join(STATIC_ROOT, 'title.png'))
for letter in string.ascii_uppercase: for letter in string.ascii_uppercase:
videos[letter] = glob('%s%s*.mp4' % (prefix, letter.lower())) videos[letter] = glob('%s%s*.mp4' % (prefix, letter.lower()))
random.shuffle(videos[letter]) random.shuffle(videos[letter])
@ -52,6 +53,11 @@ def update_playlist(playlist, prefix, position=None, shift=True):
for letter in string.ascii_uppercase: for letter in string.ascii_uppercase:
files.append(videos[letter][i]) files.append(videos[letter][i])
if not shift:
black = os.path.normpath(os.path.join(prefix, '..', 'black.mp4'))
if os.path.exists(black):
files.append(black)
if shift: if shift:
if position is None: if position is None:
today = datetime.date.today() today = datetime.date.today()