diff --git a/modules/scheduling/fallback.py b/modules/scheduling/fallback.py index 7b9b8657285899447f141196d897b373f8992429..aa0e2305c5aab2bca6ff46b285c6ad7354024f6b 100644 --- a/modules/scheduling/fallback.py +++ b/modules/scheduling/fallback.py @@ -22,6 +22,7 @@ import logging from enum import Enum +from datetime import timedelta from modules.base.config import AuraConfig from modules.base.utils import SimpleUtil as SU @@ -219,5 +220,9 @@ class FallbackCommand(EngineExecutor): self.logger.info(SU.cyan("=== stop_fallback_playlist() ===")) Engine.get_instance().player.stop_fallback_playlist() - child_timer = EngineExecutor("FALLBACK", None, timeslot.end_unix, do_stop, None) + # Start fade-out 50% before the end of the timeslot for a more smooth transition + end_time_offset = int(float(AuraConfig.config().get("fade_out_time")) / 2 * 1000 * -1) + end_time = SU.timestamp(timeslot.schedule_end + timedelta(milliseconds=end_time_offset)) + self.logger.info(f"Starting fade-out of scheduled fallback with an offset of {end_time_offset} milliseconds at {end_time}") + child_timer = EngineExecutor("FALLBACK", None, end_time, do_stop, None) super().__init__("FALLBACK", child_timer, timeslot.start_unix, do_play, entries) \ No newline at end of file