more show plan item stuffs

This commit is contained in:
michael-grace 2020-11-02 23:06:45 +00:00
parent bd0c27ddc3
commit 1e464b2247
2 changed files with 41 additions and 18 deletions

View file

@ -176,6 +176,19 @@ class Player():
self.state.update("show_plan", self.state.state["show_plan"] + [PlanObject(new_item)])
return True
def remove_from_plan(self, timeslotitemid: int) -> bool:
plan_copy = copy.copy(self.state.state["show_plan"])
for i in range(len(plan_copy)):
if plan_copy[i].timeslotitemid == timeslotitemid:
plan_copy.remove(i)
self.state.update("show_plan", plan_copy)
return True
return False
def clear_channel_plan(self) -> bool:
self.state.update("show_plan", [])
return True
def load(self, timeslotitemid: int):
if not self.isPlaying:
self.unload()
@ -330,33 +343,23 @@ class Player():
"PAUSE": lambda: self._retMsg(self.pause()),
"UNPAUSE": lambda: self._retMsg(self.unpause()),
"STOP": lambda: self._retMsg(self.stop()),
"SEEK": lambda: self._retMsg(self.seek(float(self.last_msg.split(":")[1]))),
"LOAD": lambda: self._retMsg(self.load(int(self.last_msg.split(":")[1]))),
"LOADED?": lambda: self._retMsg(self.isLoaded),
"UNLOAD": lambda: self._retMsg(self.unload()),
"STATUS": lambda: self._retMsg(self.status, True)
"STATUS": lambda: self._retMsg(self.status, True),
"ADD": lambda: self._retMsg(self.add_to_plan(json.loads(":".join(self.last_msg.split(":")[1:])))),
"REMOVE": lambda: self._retMsg(self.remove_from_plan(int(self.last_msg.split(":")[1]))),
"CLEAR": lambda: self._retMsg(self.clear_channel_plan())
}
if self.last_msg in message_types.keys():
message_types[self.last_msg]()
elif (self.last_msg == 'LOADED?'):
self._retMsg(self.isLoaded)
continue
elif (self.last_msg.startswith("ADD")):
split = self.last_msg.split(":")
self._retMsg(self.add_to_plan(json.loads(":".join(split[1:]))))
elif (self.last_msg == 'QUIT'):
self.running = False
continue
elif (self.last_msg.startswith("SEEK")):
split = self.last_msg.split(":")
self._retMsg(self.seek(float(split[1])))
elif (self.last_msg.startswith("LOAD")):
split = self.last_msg.split(":")
self._retMsg(self.load(int(split[1])))
else:
self._retMsg("Unknown Command")
else:

View file

@ -38,6 +38,7 @@ channel_to_q = []
channel_from_q = []
channel_p = []
### General Endpoints
@app.errorhandler(404)
def page_not_found(e):
@ -92,6 +93,7 @@ def ui_status():
}
return render_template('status.html', data=data)
### Channel Audio Options
@app.route("/player/<int:channel>/play")
def play(channel):
@ -138,6 +140,8 @@ def output(channel, name):
channel_to_q[channel].put("OUTPUT:" + name)
return ui_status()
### Channel Items
@app.route("/player/<int:channel>/load/<int:timeslotitemid>")
def load(channel:int, timeslotitemid: int):
channel_to_q[channel].put("LOAD:" + str(timeslotitemid))
@ -177,6 +181,15 @@ def remove_plan(channel: int, timeslotitemid: int):
#TODO Return
return True
@app.route("/player/<int:channel>/clear")
def clear_channel_plan(channel: int):
channel_to_q[channel].put("CLEAR")
#TODO Return
return True
### General Channel Endpoints
@app.route("/player/<int:channel>/status")
def status(channel):
@ -198,7 +211,14 @@ def status(channel):
def all_stop():
for channel in channel_to_q:
channel.put("STOP")
ui_status()
return ui_status()
@app.route("/player/all/clear")
def clear_all_channels():
for channel in channel_to_q:
channel.put("CLEAR")
return ui_status()
@app.route('/static/<path:path>')