Fix setting markers from presenter
This commit is contained in:
parent
9af1538d0b
commit
f42a3147df
2 changed files with 14 additions and 7 deletions
16
player.py
16
player.py
|
@ -429,7 +429,8 @@ class Player:
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def set_marker(self, timeslotitemid: int, marker_str: str):
|
# Timeslotitemid can be a ghost (un-submitted item), so may be "IXXX"
|
||||||
|
def set_marker(self, timeslotitemid: str, marker_str: str):
|
||||||
set_loaded = False
|
set_loaded = False
|
||||||
success = True
|
success = True
|
||||||
try:
|
try:
|
||||||
|
@ -438,7 +439,7 @@ class Player:
|
||||||
self.logger.log.error("Failed to create Marker instance with {} {}: {}".format(timeslotitemid, marker_str, e))
|
self.logger.log.error("Failed to create Marker instance with {} {}: {}".format(timeslotitemid, marker_str, e))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if timeslotitemid == -1:
|
if timeslotitemid == "-1":
|
||||||
set_loaded = True
|
set_loaded = True
|
||||||
if not self.isLoaded:
|
if not self.isLoaded:
|
||||||
return False
|
return False
|
||||||
|
@ -449,7 +450,7 @@ class Player:
|
||||||
|
|
||||||
item = plan_copy[i]
|
item = plan_copy[i]
|
||||||
|
|
||||||
if item.timeslotitemid == timeslotitemid:
|
if str(item.timeslotitemid) == str(timeslotitemid):
|
||||||
try:
|
try:
|
||||||
new_item = item.set_marker(marker)
|
new_item = item.set_marker(marker)
|
||||||
self.state.update("show_plan", new_item, index=i)
|
self.state.update("show_plan", new_item, index=i)
|
||||||
|
@ -522,6 +523,7 @@ class Player:
|
||||||
elif self.isPlaying:
|
elif self.isPlaying:
|
||||||
# Get one last update in, incase we're about to pause/stop it.
|
# Get one last update in, incase we're about to pause/stop it.
|
||||||
self.state.update("pos", max(0, mixer.music.get_pos() / 1000))
|
self.state.update("pos", max(0, mixer.music.get_pos() / 1000))
|
||||||
|
# TODO this is wrong now we don't pause the mixer.
|
||||||
elif not self.isPaused:
|
elif not self.isPaused:
|
||||||
self.state.update("pos", 0) # Reset back to 0 if stopped.
|
self.state.update("pos", 0) # Reset back to 0 if stopped.
|
||||||
self.state.update("pos_offset", 0)
|
self.state.update("pos_offset", 0)
|
||||||
|
@ -558,7 +560,7 @@ class Player:
|
||||||
or self.last_time_update + UPDATES_FREQ_SECS < time.time()
|
or self.last_time_update + UPDATES_FREQ_SECS < time.time()
|
||||||
):
|
):
|
||||||
self.last_time_update = time.time()
|
self.last_time_update = time.time()
|
||||||
self._retAll("POS:" + str(int(self.state.state["pos_true"])))
|
self._retAll("POS:" + str(self.state.state["pos_true"]))
|
||||||
|
|
||||||
def _retAll(self, msg):
|
def _retAll(self, msg):
|
||||||
self.out_q.put("ALL:" + msg)
|
self.out_q.put("ALL:" + msg)
|
||||||
|
@ -582,7 +584,7 @@ class Player:
|
||||||
response += "FAIL"
|
response += "FAIL"
|
||||||
self.logger.log.debug(("Preparing to send: {}".format(response)))
|
self.logger.log.debug(("Preparing to send: {}".format(response)))
|
||||||
if self.out_q:
|
if self.out_q:
|
||||||
self.logger.log.info(("Sending: {}".format(response)))
|
self.logger.log.debug(("Sending: {}".format(response)))
|
||||||
self.out_q.put(response)
|
self.out_q.put(response)
|
||||||
|
|
||||||
def _send_status(self):
|
def _send_status(self):
|
||||||
|
@ -666,7 +668,7 @@ class Player:
|
||||||
self.last_msg_source = source
|
self.last_msg_source = source
|
||||||
self.last_msg = message.split(":", 1)[1]
|
self.last_msg = message.split(":", 1)[1]
|
||||||
|
|
||||||
self.logger.log.info(
|
self.logger.log.debug(
|
||||||
"Recieved message from source {}: {}".format(
|
"Recieved message from source {}: {}".format(
|
||||||
self.last_msg_source, self.last_msg
|
self.last_msg_source, self.last_msg
|
||||||
)
|
)
|
||||||
|
@ -731,7 +733,7 @@ class Player:
|
||||||
int(self.last_msg.split(":")[1]))
|
int(self.last_msg.split(":")[1]))
|
||||||
),
|
),
|
||||||
"CLEAR": lambda: self._retMsg(self.clear_channel_plan()),
|
"CLEAR": lambda: self._retMsg(self.clear_channel_plan()),
|
||||||
"SETMARKER": lambda: self._retMsg(self.set_marker(int(self.last_msg.split(":")[1]), self.last_msg.split(":", 2)[2])),
|
"SETMARKER": lambda: self._retMsg(self.set_marker(self.last_msg.split(":")[1], self.last_msg.split(":", 2)[2])),
|
||||||
}
|
}
|
||||||
|
|
||||||
message_type: str = self.last_msg.split(":")[0]
|
message_type: str = self.last_msg.split(":")[0]
|
||||||
|
|
|
@ -139,6 +139,11 @@ class WebsocketServer:
|
||||||
extra += str(data["weight"])
|
extra += str(data["weight"])
|
||||||
elif command == "GET_PLAN":
|
elif command == "GET_PLAN":
|
||||||
extra += str(data["timeslotId"])
|
extra += str(data["timeslotId"])
|
||||||
|
elif command == "SETMARKER":
|
||||||
|
extra += "{}:{}".format(
|
||||||
|
data["timeslotitemid"],
|
||||||
|
json.dumps(data["marker"])
|
||||||
|
)
|
||||||
|
|
||||||
# SPECIAL CASE ALERT! We need to talk to two channels here.
|
# SPECIAL CASE ALERT! We need to talk to two channels here.
|
||||||
elif command == "MOVE":
|
elif command == "MOVE":
|
||||||
|
|
Loading…
Reference in a new issue