diff --git a/src/aura_engine/scheduling/scheduler.py b/src/aura_engine/scheduling/scheduler.py index 4a46b220b560cd690b78752dce9194951716da80..8d2a3613d3bfc59fa62f62ffec91935efaf65c14 100644 --- a/src/aura_engine/scheduling/scheduler.py +++ b/src/aura_engine/scheduling/scheduler.py @@ -200,8 +200,9 @@ class PlayCommand(EngineExecutor): self.logger.info(SU.cyan(f"=== play('{items_str}') ===")) last_item: PlaylistItem = items[-1] - # FIXME: this never breaks and keeps displaying the message in come faulty edge cases, + # FIXME: this never breaks and keeps displaying the message in some faulty edge cases, # even after the timeslot ends + timeout = 0 while not last_item.play.is_ready(): now = SU.timestamp() if now - last_log > log_interval: @@ -210,6 +211,21 @@ class PlayCommand(EngineExecutor): if last_item.play.state == PlayState.PlayStateType.TIMEOUT: self.logger.warn(SU.red("PLAY: Preloading timed out.")) break + # FIXME: could this be handled inside PlayState which would then set its type to + # TIMEOUT itself? + if last_item.play.state is None: + timeout += 1 + else: + timeout = 0 + + if last_item.play.state is None and timeout >= 15: + self.logger.error( + SU.red( + "PLAY: Aborting preload after 15 seconds since the play state is still None." + ) + ) + break + self.logger.debug(f"PLAY: STATE({last_item.play.state})") time.sleep(1) self.engine.player.play(items[0], engine.Player.TransitionType.FADE) timetable_renderer: utils.TimetableRenderer = self.engine.scheduler.timetable_renderer