Add fader live tracking to player
This commit is contained in:
parent
e821df5585
commit
3951a4b427
4 changed files with 40 additions and 12 deletions
29
player.py
29
player.py
|
@ -81,6 +81,7 @@ class Player:
|
||||||
"play_on_load": False,
|
"play_on_load": False,
|
||||||
"output": None,
|
"output": None,
|
||||||
"show_plan": [],
|
"show_plan": [],
|
||||||
|
"live": True,
|
||||||
"tracklist_mode": "off",
|
"tracklist_mode": "off",
|
||||||
"tracklist_id": None,
|
"tracklist_id": None,
|
||||||
}
|
}
|
||||||
|
@ -597,6 +598,16 @@ class Player:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
if (live):
|
||||||
|
self._potentially_tracklist()
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
|
|
||||||
|
@ -605,7 +616,7 @@ class Player:
|
||||||
mode = self.state.get()["tracklist_mode"]
|
mode = self.state.get()["tracklist_mode"]
|
||||||
|
|
||||||
time: int = -1
|
time: int = -1
|
||||||
if mode == "on":
|
if mode in ["on","fader-live"]:
|
||||||
time = 1 # Let's do it pretty quickly.
|
time = 1 # Let's do it pretty quickly.
|
||||||
elif mode == "delayed":
|
elif mode == "delayed":
|
||||||
# Let's do it in a bit, once we're sure it's been playing. (Useful if we've got no idea if it's live or cueing.)
|
# Let's do it in a bit, once we're sure it's been playing. (Useful if we've got no idea if it's live or cueing.)
|
||||||
|
@ -652,13 +663,21 @@ class Player:
|
||||||
self.logger.log.warning("Failed to potentially end tracklist, no tracklist started.")
|
self.logger.log.warning("Failed to potentially end tracklist, no tracklist started.")
|
||||||
|
|
||||||
def _tracklist_start(self):
|
def _tracklist_start(self):
|
||||||
loaded_item = self.state.get()["loaded_item"]
|
state = self.state.get()
|
||||||
|
loaded_item = state["loaded_item"]
|
||||||
if not loaded_item:
|
if not loaded_item:
|
||||||
self.logger.log.error("Tried to call _tracklist_start() with no loaded item!")
|
self.logger.log.error("Tried to call _tracklist_start() with no loaded item!")
|
||||||
return
|
return
|
||||||
|
|
||||||
tracklist_id = self.state.get()["tracklist_id"]
|
if not self.isPlaying:
|
||||||
|
self.logger.log.info("Not tracklisting since not playing.")
|
||||||
|
return
|
||||||
|
|
||||||
|
tracklist_id = state["tracklist_id"]
|
||||||
if (not tracklist_id):
|
if (not tracklist_id):
|
||||||
|
if (state["tracklist_mode"] == "fader-live" and not state["live"]):
|
||||||
|
self.logger.log.info("Not tracklisting since fader is not live.")
|
||||||
|
else:
|
||||||
self.logger.log.info("Tracklisting item: {}".format(loaded_item.name))
|
self.logger.log.info("Tracklisting item: {}".format(loaded_item.name))
|
||||||
tracklist_id = self.api.post_tracklist_start(loaded_item)
|
tracklist_id = self.api.post_tracklist_start(loaded_item)
|
||||||
if not tracklist_id:
|
if not tracklist_id:
|
||||||
|
@ -865,6 +884,7 @@ class Player:
|
||||||
|
|
||||||
self.state.update("channel", channel)
|
self.state.update("channel", channel)
|
||||||
self.state.update("tracklist_mode", server_state.get()["tracklist_mode"])
|
self.state.update("tracklist_mode", server_state.get()["tracklist_mode"])
|
||||||
|
self.state.update("live", True) # Channel is live until controller says it isn't.
|
||||||
|
|
||||||
# Just in case there's any weights somehow messed up, let's fix them.
|
# Just in case there's any weights somehow messed up, let's fix them.
|
||||||
plan_copy: List[PlanItem] = copy.copy(self.state.get()["show_plan"])
|
plan_copy: List[PlanItem] = copy.copy(self.state.get()["show_plan"])
|
||||||
|
@ -986,7 +1006,8 @@ class Player:
|
||||||
),
|
),
|
||||||
"CLEAR": lambda: self._retMsg(self.clear_channel_plan()),
|
"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])),
|
"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])))
|
"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])),
|
||||||
}
|
}
|
||||||
|
|
||||||
message_type: str = self.last_msg.split(":")[0]
|
message_type: str = self.last_msg.split(":")[0]
|
||||||
|
|
|
@ -44,7 +44,10 @@
|
||||||
<option value="{{mode}}" {% if mode == data.state.tracklist_mode %}selected{% endif %}>{{ mode.capitalize() }}</option>
|
<option value="{{mode}}" {% if mode == data.state.tracklist_mode %}selected{% endif %}>{{ mode.capitalize() }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<p><small>Delayed tracklisting is 20s, to account for cueing with fader down.</small></p>
|
<p><small>
|
||||||
|
Delayed tracklisting is 20s, to account for cueing with fader down.<br>
|
||||||
|
Fader Live means if a BAPS Controller is present with support, tracklists will trigger only if fader is up.
|
||||||
|
</small></p>
|
||||||
<hr>
|
<hr>
|
||||||
<input type="submit" class="btn btn-primary" value="Save & Restart Server">
|
<input type="submit" class="btn btn-primary" value="Save & Restart Server">
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
{% if player %}
|
{% if player %}
|
||||||
<h3 class="h5">Player {{player.channel}}</h3>
|
<h3 class="h5">Player {{player.channel}}</h3>
|
||||||
|
<p>
|
||||||
|
Initialised: {{player.initialised}}<br/>
|
||||||
|
Fader Live: {{player.live}}
|
||||||
|
</p>
|
||||||
<a href="/player/{{player.channel}}/play">Play</a>
|
<a href="/player/{{player.channel}}/play">Play</a>
|
||||||
{% if player.paused %}
|
{% if player.paused %}
|
||||||
<a href="/player/{{player.channel}}/unpause">UnPause</a>
|
<a href="/player/{{player.channel}}/unpause">UnPause</a>
|
||||||
|
|
|
@ -100,7 +100,7 @@ def ui_config_server(request):
|
||||||
"ui_title": "Server Config",
|
"ui_title": "Server Config",
|
||||||
"state": server_state.get(),
|
"state": server_state.get(),
|
||||||
"ser_ports": DeviceManager.getSerialPorts(),
|
"ser_ports": DeviceManager.getSerialPorts(),
|
||||||
"tracklist_modes": ["off", "on", "delayed"]
|
"tracklist_modes": ["off", "on", "delayed", "fader-live"]
|
||||||
}
|
}
|
||||||
return render_template("config_server.html", data=data)
|
return render_template("config_server.html", data=data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue