diff --git a/hugvey/central_command.py b/hugvey/central_command.py index f3fa4e4..e1c8177 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -349,6 +349,18 @@ class HugveyState(object): if event['event'] == 'change_language': self.setLanguage(event['lang_code']) + if event['event'] == 'play_msg': + self.logger.info("DO PLAY :-)") + if not self.story: + self.logger.critical("No story to play message in") + else: + msg = self.story.get(event['msg_id']) +# if not msg or isinstance(msg, hugvey.story.Message): +# self.logger.critical("Invalid ID to play: {}".format(event['msg_id'])) + self.restart() + await asyncio.sleep(.1) + self.story.setCurrentMessage(msg) +# self.resume() # don't reset a finished story self.eventQueue = None @@ -375,6 +387,7 @@ class HugveyState(object): self.status = self.STATE_PAUSE def resume(self): + """ Start playing without reset""" self.logger.info('Resume') if self.google: self.google.resume() @@ -384,6 +397,7 @@ class HugveyState(object): self.status = self.STATE_RUNNING def restart(self): + """ Start playing with reset""" self.logger.info('Restart') if self.story: self.story.stop() diff --git a/hugvey/panopticon.py b/hugvey/panopticon.py index f280a1e..416fba3 100644 --- a/hugvey/panopticon.py +++ b/hugvey/panopticon.py @@ -55,6 +55,8 @@ def getWebSocketHandler(central_command): self.msgRestart(msg['hugvey']) elif msg['action'] == 'change_language': self.msgChangeLanguage(msg['hugvey'], msg['lang_code']) + elif msg['action'] == 'play_msg': + self.msgPlayMsg(msg['hugvey'], msg['msg_id']) else: self.send({'alert': 'Unknown request: {}'.format(message)}) logger.warn('Unknown request: {}'.format(message)) @@ -96,6 +98,9 @@ def getWebSocketHandler(central_command): def msgChangeLanguage(self, hv_id, lang_code): central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language', 'lang_code': lang_code}) + + def msgPlayMsg(self, hv_id, msg_id): + central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'play_msg', 'msg_id': msg_id}) return WebSocketHandler diff --git a/www/css/styles.css b/www/css/styles.css index b4bec5b..1aaa28e 100644 --- a/www/css/styles.css +++ b/www/css/styles.css @@ -154,13 +154,19 @@ img.icon { position: absolute; top: 0; right: 0; - width: 30%; + width: 420px; max-height: 100%; overflow-y: auto; } #story #msg .msg__info, #story #msg .directions > div { padding: 10px; margin-bottom: 10px; background: lightgray; } + #story #msg h1 { + margin: 0; } + #story #msg .play { + position: absolute; + top: 15px; + right: 10px; } #story #msg .direction { position: relative; } #story #msg .direction h3 { diff --git a/www/index.html b/www/index.html index 620f4d8..fb867df 100644 --- a/www/index.html +++ b/www/index.html @@ -64,6 +64,7 @@