diff --git a/controllers/mattchbox_usb.py b/controllers/mattchbox_usb.py index 2f4c714..5f22777 100644 --- a/controllers/mattchbox_usb.py +++ b/controllers/mattchbox_usb.py @@ -58,6 +58,10 @@ class MattchBox(Controller): self.next_port = new_port def connect(self, port: Optional[str]): + # If we loose the controller, make sure to set channels live, so we tracklist. + for i in range(len(self.server_from_q)): + self.sendToPlayer(i, "SETLIVE:True") + if port: # connect to serial port self.ser = serial.serial_for_url(port, do_not_open=True) @@ -85,7 +89,13 @@ class MattchBox(Controller): ) # Endianness doesn't matter for 1 byte. self.logger.log.info("Received from controller: " + str(line)) if line == 255: - self.ser.write(b"\xff") # Send 255 back. + self.ser.write(b"\xff") # Send 255 back + elif line in [51,52,53]: + # We've received a status update about fader live status, fader is down. + self.sendToPlayer(line-51, "SETLIVE:False") + elif line in [61,62,63]: + # We've received a status update about fader live status, fader is up. + self.sendToPlayer(line-61, "SETLIVE:True") elif line in [1, 3, 5]: self.sendToPlayer(int(line / 2), "PLAYPAUSE") elif line in [2, 4, 6]: @@ -121,5 +131,5 @@ class MattchBox(Controller): self.connect(None) def sendToPlayer(self, channel: int, msg: str): - self.logger.log.info("Sending message to server: " + msg) + self.logger.log.info("Sending message to player channel {}: {}".format(channel, msg)) self.server_to_q[channel].put("CONTROLLER:" + msg) diff --git a/player.py b/player.py index db05d47..34fedf3 100644 --- a/player.py +++ b/player.py @@ -600,7 +600,7 @@ class Player: # Tells the player that the fader is live on-air, so it can tell tracklisting from PFL def set_live(self, live: bool): - live = bool(live) + self.state.update("live", live) # If we're going to live (potentially from not live/PFL), potentially tracklist if it's playing. @@ -1007,7 +1007,7 @@ class Player: "CLEAR": lambda: self._retMsg(self.clear_channel_plan()), "SETMARKER": lambda: self._retMsg(self.set_marker(self.last_msg.split(":")[1], self.last_msg.split(":", 2)[2])), "RESETPLAYED": lambda: self._retMsg(self.reset_played(int(self.last_msg.split(":")[1]))), - "SETLIVE": lambda: self._retMsg(self.set_live(self.last_msg.split(":")[1])), + "SETLIVE": lambda: self._retMsg(self.set_live(self.last_msg.split(":")[1] == "True")), } message_type: str = self.last_msg.split(":")[0]