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')
player = None
quit = False
def q_binding(*args):
global player
player.quit()
del player
quit = True
def main():
@ -56,9 +58,21 @@ def main():
if not shift:
player.pause = True
pause_next = False
play_lights = 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())
play_lights = True
try:
player.wait_for_playback()
except:

View file

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

View file

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