fix: start each schedule item at its planned time

Start played the first item right away, although the plan begins at
the next full hour. The news was at :00 and :30 in the plan but not on
the real clock.

PlaybackEngine now takes a clock and waits before each item until its
planned start. An item that runs late is never cut; the next one then
starts right after it. When the broadcast starts after the plan has
begun, items that should already have started are skipped and playback
joins at the next one.

While the engine waits for the first item, the now-playing card shows
"On air at" with the planned time. Starting a plan that is already
over is refused with a message.

Refs #12

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
fraujulianandClaude Opus 5.5 committed 2026-11-23 11:20:10 +01:00
1 parent 6f3ce85307
commit 497ac8fd6c
6 files changed
+127 -17

No files matched your search

@@ -97,7 +97,14 @@ public partial class SchedulePage : Page
private void OnStart(object sender, RoutedEventArgs e)
{
Message.IsOpen = false;
_controller.Start();
try
{
_controller.Start();
}
catch (InvalidOperationException ex)
{
ShowMessage(InfoBarSeverity.Warning, "Could not start", ex.Message);
}
ShowCurrent();
}
@@ -145,7 +152,7 @@ public partial class SchedulePage : Page
NowKind.Content = item;
NowKind.Visibility = item is null ? Visibility.Collapsed : Visibility.Visible;
NowTitle.Text = item?.Title ?? "Nothing on air";
if (item is not null) NowTitle.Text = item.Title;
UpdateButtons();
UpdateProgress();
@@ -175,7 +182,10 @@ public partial class SchedulePage : Page
if (_controller.CurrentItem is not { } item)
{
NowProgress.Value = 0;
NowTime.Text = " ";
// Checked here, not in ShowCurrent: the engine starts waiting a moment after Start.
var waiting = _controller.WaitingUntil;
NowTitle.Text = waiting is { } at ? $"On air at {at:HH:mm:ss}" : "Nothing on air";
NowTime.Text = waiting is null ? " " : "Waiting for the planned start, so the news comes at :00 and :30.";
return;
}