tidy up some messages

This commit is contained in:
michael-grace 2020-11-01 02:37:56 +00:00
parent 330cc32be2
commit bd0c27ddc3
2 changed files with 16 additions and 20 deletions

4
.gitignore vendored
View file

@ -24,4 +24,6 @@ build/output/
venv/ venv/
config.py config.py
dev/test.mp3

View file

@ -325,7 +325,19 @@ class Player():
elif self.isInit: elif self.isInit:
if (self.last_msg == 'LOADED?'): message_types: Dict[str, Callable[any, bool]] = { # TODO Check Types
"PLAY": lambda: self._retMsg(self.play()),
"PAUSE": lambda: self._retMsg(self.pause()),
"UNPAUSE": lambda: self._retMsg(self.unpause()),
"STOP": lambda: self._retMsg(self.stop()),
"UNLOAD": lambda: self._retMsg(self.unload()),
"STATUS": lambda: self._retMsg(self.status, True)
}
if self.last_msg in message_types.keys():
message_types[self.last_msg]()
elif (self.last_msg == 'LOADED?'):
self._retMsg(self.isLoaded) self._retMsg(self.isLoaded)
continue continue
@ -333,18 +345,6 @@ class Player():
split = self.last_msg.split(":") split = self.last_msg.split(":")
self._retMsg(self.add_to_plan(json.loads(":".join(split[1:])))) self._retMsg(self.add_to_plan(json.loads(":".join(split[1:]))))
elif (self.last_msg == 'PLAY'):
self._retMsg(self.play())
elif (self.last_msg == 'PAUSE'):
self._retMsg(self.pause())
elif (self.last_msg == 'UNPAUSE'):
self._retMsg(self.unpause())
elif (self.last_msg == 'STOP'):
self._retMsg(self.stop())
elif (self.last_msg == 'QUIT'): elif (self.last_msg == 'QUIT'):
self.running = False self.running = False
continue continue
@ -357,12 +357,6 @@ class Player():
split = self.last_msg.split(":") split = self.last_msg.split(":")
self._retMsg(self.load(int(split[1]))) self._retMsg(self.load(int(split[1])))
elif (self.last_msg == 'UNLOAD'):
self._retMsg(self.unload())
elif (self.last_msg == 'STATUS'):
self._retMsg(self.status, True)
else: else:
self._retMsg("Unknown Command") self._retMsg("Unknown Command")
else: else: