feat(schedule): add a button to stop the current item

"Aktuelles Element stoppen" in the now-playing card sets the length of
the item on air to the time from its start until now, so the next item
starts at once. Brings back ScheduleController.EndCurrentNow and its
tests; the separate start/stop button stays removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
fraujulianandClaude Opus 5.5 committed 2026-11-27 08:15:14 +01:00
1 parent 6c3396ab4d
commit a47da65f3d
7 files changed
+73 -1

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@ The interface is in German. This section names the controls as they appear on sc
- **Jetzt starten** starts the plan you created. A **Jetzt** plan moves to the moment you press it, so nothing is skipped while you looked it over. It stays disabled until a plan exists. While laut.fm is switched on the button reads **Live starten** and also starts the live stream; if laut.fm cannot be reached, the music still plays and a warning says why. While on air the button turns red and reads **Sendung beenden**, which stops playback and the live stream together. - **Jetzt starten** starts the plan you created. A **Jetzt** plan moves to the moment you press it, so nothing is skipped while you looked it over. It stays disabled until a plan exists. While laut.fm is switched on the button reads **Live starten** and also starts the live stream; if laut.fm cannot be reached, the music still plays and a warning says why. While on air the button turns red and reads **Sendung beenden**, which stops playback and the live stream together.
2. The timeline shows every item with start time, type (song, news, ad, moderator), title and duration. 2. The timeline shows every item with start time, type (song, news, ad, moderator), title and duration.
3. The now-playing card shows the current item and its progress. Before the planned start it shows when the broadcast begins; if the plan has already begun, playback joins at the next item. 3. The now-playing card shows the current item and its progress. Before the planned start it shows when the broadcast begins; if the plan has already begun, playback joins at the next item.
4. **Edit the timeline**: select an upcoming row and use the buttons above the list to move it up or down, edit it, or remove it (trash icon), or drag it to a new place with the mouse: a label with type and title follows the cursor, a line shows where it lands, and the row fades in at its new place. The grip on the left of a row shows it can be dragged. **HinzufĂĽgen** inserts a song (the one chosen under **Songwunsch**), news, an ad or moderator talk as the item after next: two places after the item on air, or at position 3 of the list when nothing is on air; for everything but songs you set title and length first. News, ad and moderator items have no title until you give them one; news and moderator items can also change their length. A double-click opens the editor too. Every item after a change follows on without a gap. The item on air can be edited too, but not moved or removed. 4. **Edit the timeline**: select an upcoming row and use the buttons above the list to move it up or down, edit it, or remove it (trash icon), or drag it to a new place with the mouse: a label with type and title follows the cursor, a line shows where it lands, and the row fades in at its new place. The grip on the left of a row shows it can be dragged. **HinzufĂĽgen** inserts a song (the one chosen under **Songwunsch**), news, an ad or moderator talk as the item after next: two places after the item on air, or at position 3 of the list when nothing is on air; for everything but songs you set title and length first. News, ad and moderator items have no title until you give them one; news and moderator items can also change their length. A double-click opens the editor too. Every item after a change follows on without a gap. The item on air can be edited too, but not moved or removed; **Aktuelles Element stoppen** in the now-playing card ends it at once: its length becomes the time from its start until now, and the next item starts.
5. **Speaking reminder**: 30 seconds before a news or moderator item goes on air, a dialog in the middle of the screen reminds you on any page and stays until you click **OK**. 5. **Speaking reminder**: 30 seconds before a news or moderator item goes on air, a dialog in the middle of the screen reminds you on any page and stays until you click **OK**.
6. **Microphone**: **Mikro ein** in the now-playing card puts the default microphone on air, also over running music; the button turns red and reads **Mikro aus**. It works with or without a broadcast and stays on while you visit other pages. 6. **Microphone**: **Mikro ein** in the now-playing card puts the default microphone on air, also over running music; the button turns red and reads **Mikro aus**. It works with or without a broadcast and stays on while you visit other pages.
7. **Mix levels**, below the now-playing row: under **Was die Hörer hören**, **Musik** and **Mikrofon** set how loud the music and the microphone are for the listeners. Under **Was du hörst**, **Musik** sets how loud the music is on your own device; you never hear your own microphone there, because the delay is distracting. **Genau wie die Hörer** lets you hear exactly what the listeners hear, microphone included. 7. **Mix levels**, below the now-playing row: under **Was die Hörer hören**, **Musik** and **Mikrofon** set how loud the music and the microphone are for the listeners. Under **Was du hörst**, **Musik** sets how loud the music is on your own device; you never hear your own microphone there, because the delay is distracting. **Genau wie die Hörer** lets you hear exactly what the listeners hear, microphone included.
@@ -190,6 +190,22 @@ public class ScheduleController
/// <exception cref="ScheduleException">Item on air or over.</exception> /// <exception cref="ScheduleException">Item on air or over.</exception>
public IReadOnlyList<ScheduleItem> Remove(int index) => Change(index, change: items => items.RemoveAt(index)); public IReadOnlyList<ScheduleItem> Remove(int index) => Change(index, change: items => items.RemoveAt(index));
/// <exception cref="ScheduleException">Nothing on air.</exception>
public IReadOnlyList<ScheduleItem> EndCurrentNow()
{
var index = CurrentIndex;
if (CurrentItem is null)
throw new ScheduleException(Loc.T("Schedule_NothingOnAirError"));
var now = _now();
// Whole seconds: next start not in the future.
var end = new DateTime(now.Ticks - now.Ticks % TimeSpan.TicksPerSecond, now.Kind);
return Change(index, currentAllowed: true, change: items =>
{
var item = items[index];
items[index] = item with { Duration = end > item.Start ? end - item.Start : TimeSpan.Zero };
});
}
/// <exception cref="ScheduleException">Edit not allowed for item, or item over.</exception> /// <exception cref="ScheduleException">Edit not allowed for item, or item over.</exception>
public IReadOnlyList<ScheduleItem> EditItem(int index, string title, TimeSpan duration) => Change(index, currentAllowed: true, change: items => public IReadOnlyList<ScheduleItem> EditItem(int index, string title, TimeSpan duration) => Change(index, currentAllowed: true, change: items =>
{ {
@@ -120,6 +120,9 @@
<data name="Schedule_Empty" xml:space="preserve"><value>No schedule yet. Choose the hours and create a schedule.</value></data> <data name="Schedule_Empty" xml:space="preserve"><value>No schedule yet. Choose the hours and create a schedule.</value></data>
<data name="Schedule_EndBroadcast" xml:space="preserve"><value>End broadcast</value></data> <data name="Schedule_EndBroadcast" xml:space="preserve"><value>End broadcast</value></data>
<data name="Schedule_EndBroadcastFailed" xml:space="preserve"><value>The broadcast could not be ended</value></data> <data name="Schedule_EndBroadcastFailed" xml:space="preserve"><value>The broadcast could not be ended</value></data>
<data name="Schedule_EndItemFailed" xml:space="preserve"><value>The item could not be ended</value></data>
<data name="Schedule_EndNow" xml:space="preserve"><value>Stop current item</value></data>
<data name="Schedule_EndNowTip" xml:space="preserve"><value>Ends the current item right away; the next one starts.</value></data>
<data name="Schedule_ExtendFailed" xml:space="preserve"><value>The schedule could not be extended: {0}</value></data> <data name="Schedule_ExtendFailed" xml:space="preserve"><value>The schedule could not be extended: {0}</value></data>
<data name="Schedule_Finished" xml:space="preserve"><value>Broadcast ended</value></data> <data name="Schedule_Finished" xml:space="preserve"><value>Broadcast ended</value></data>
<data name="Schedule_FinishedText" xml:space="preserve"><value>The whole schedule has been played.</value></data> <data name="Schedule_FinishedText" xml:space="preserve"><value>The whole schedule has been played.</value></data>
@@ -156,6 +159,7 @@
<data name="Schedule_NoSong" xml:space="preserve"><value>No song selected</value></data> <data name="Schedule_NoSong" xml:space="preserve"><value>No song selected</value></data>
<data name="Schedule_NoSongText" xml:space="preserve"><value>First choose a song under “Song request”.</value></data> <data name="Schedule_NoSongText" xml:space="preserve"><value>First choose a song under “Song request”.</value></data>
<data name="Schedule_NothingOnAir" xml:space="preserve"><value>Nothing on air</value></data> <data name="Schedule_NothingOnAir" xml:space="preserve"><value>Nothing on air</value></data>
<data name="Schedule_NothingOnAirError" xml:space="preserve"><value>Nothing is on air.</value></data>
<data name="Schedule_Now" xml:space="preserve"><value>Now</value></data> <data name="Schedule_Now" xml:space="preserve"><value>Now</value></data>
<data name="Schedule_NowPlaying" xml:space="preserve"><value>On air now</value></data> <data name="Schedule_NowPlaying" xml:space="preserve"><value>On air now</value></data>
<data name="Schedule_OnAirLocked" xml:space="preserve"><value>This item is on air. It can be edited or ended, but not moved or removed.</value></data> <data name="Schedule_OnAirLocked" xml:space="preserve"><value>This item is on air. It can be edited or ended, but not moved or removed.</value></data>
@@ -120,6 +120,9 @@
<data name="Schedule_Empty" xml:space="preserve"><value>Noch kein Plan. Stunden wählen und Plan erstellen.</value></data> <data name="Schedule_Empty" xml:space="preserve"><value>Noch kein Plan. Stunden wählen und Plan erstellen.</value></data>
<data name="Schedule_EndBroadcast" xml:space="preserve"><value>Sendung beenden</value></data> <data name="Schedule_EndBroadcast" xml:space="preserve"><value>Sendung beenden</value></data>
<data name="Schedule_EndBroadcastFailed" xml:space="preserve"><value>Die Sendung konnte nicht beendet werden</value></data> <data name="Schedule_EndBroadcastFailed" xml:space="preserve"><value>Die Sendung konnte nicht beendet werden</value></data>
<data name="Schedule_EndItemFailed" xml:space="preserve"><value>Das Element konnte nicht beendet werden</value></data>
<data name="Schedule_EndNow" xml:space="preserve"><value>Aktuelles Element stoppen</value></data>
<data name="Schedule_EndNowTip" xml:space="preserve"><value>Beendet das laufende Element sofort; das nächste startet.</value></data>
<data name="Schedule_ExtendFailed" xml:space="preserve"><value>Der Plan konnte nicht verlängert werden: {0}</value></data> <data name="Schedule_ExtendFailed" xml:space="preserve"><value>Der Plan konnte nicht verlängert werden: {0}</value></data>
<data name="Schedule_Finished" xml:space="preserve"><value>Sendung beendet</value></data> <data name="Schedule_Finished" xml:space="preserve"><value>Sendung beendet</value></data>
<data name="Schedule_FinishedText" xml:space="preserve"><value>Der ganze Plan wurde gespielt.</value></data> <data name="Schedule_FinishedText" xml:space="preserve"><value>Der ganze Plan wurde gespielt.</value></data>
@@ -156,6 +159,7 @@
<data name="Schedule_NoSong" xml:space="preserve"><value>Kein Song gewählt</value></data> <data name="Schedule_NoSong" xml:space="preserve"><value>Kein Song gewählt</value></data>
<data name="Schedule_NoSongText" xml:space="preserve"><value>Wähle zuerst unter „Songwunsch“ einen Song.</value></data> <data name="Schedule_NoSongText" xml:space="preserve"><value>Wähle zuerst unter „Songwunsch“ einen Song.</value></data>
<data name="Schedule_NothingOnAir" xml:space="preserve"><value>Nichts auf Sendung</value></data> <data name="Schedule_NothingOnAir" xml:space="preserve"><value>Nichts auf Sendung</value></data>
<data name="Schedule_NothingOnAirError" xml:space="preserve"><value>Es ist nichts auf Sendung.</value></data>
<data name="Schedule_Now" xml:space="preserve"><value>Jetzt</value></data> <data name="Schedule_Now" xml:space="preserve"><value>Jetzt</value></data>
<data name="Schedule_NowPlaying" xml:space="preserve"><value>Läuft gerade</value></data> <data name="Schedule_NowPlaying" xml:space="preserve"><value>Läuft gerade</value></data>
<data name="Schedule_OnAirLocked" xml:space="preserve"><value>Dieses Element ist auf Sendung. Es kann bearbeitet oder beendet, aber nicht verschoben oder entfernt werden.</value></data> <data name="Schedule_OnAirLocked" xml:space="preserve"><value>Dieses Element ist auf Sendung. Es kann bearbeitet oder beendet, aber nicht verschoben oder entfernt werden.</value></data>
@@ -134,10 +134,17 @@
<!-- Live microphone on the program channel; label and icon say whether it is on. --> <!-- Live microphone on the program channel; label and icon say whether it is on. -->
<ui:Button x:Name="MicButton" <ui:Button x:Name="MicButton"
MinWidth="120" MinWidth="120"
Margin="0,0,20,0"
Content="{l:Tr Schedule_MicOn}" Content="{l:Tr Schedule_MicOn}"
Icon="{ui:SymbolIcon Mic24}" Icon="{ui:SymbolIcon Mic24}"
ToolTip="{l:Tr Schedule_MicTip}" ToolTip="{l:Tr Schedule_MicTip}"
Click="OnMicToggle" /> Click="OnMicToggle" />
<ui:Button x:Name="EndNowButton"
Content="{l:Tr Schedule_EndNow}"
Icon="{ui:SymbolIcon Stop24}"
ToolTip="{l:Tr Schedule_EndNowTip}"
IsEnabled="False"
Click="OnEndNow" />
</StackPanel> </StackPanel>
</Grid> </Grid>
@@ -311,6 +311,20 @@ public partial class SchedulePage : Page
System.Windows.Automation.AutomationProperties.SetName(StartNowButton, (string)StartNowButton.Content); System.Windows.Automation.AutomationProperties.SetName(StartNowButton, (string)StartNowButton.Content);
} }
private void OnEndNow(object sender, RoutedEventArgs e)
{
try
{
_controller.EndCurrentNow();
Message.IsOpen = false;
}
catch (ScheduleException ex)
{
ShowMessage(InfoBarSeverity.Error, Loc.T("Schedule_EndItemFailed"), ex.Message);
}
ShowCurrent();
}
private void OnRemove(object sender, RoutedEventArgs e) => ChangeSelected(row => _controller.Remove(row.Index)); private void OnRemove(object sender, RoutedEventArgs e) => ChangeSelected(row => _controller.Remove(row.Index));
private void OnAddItem(object sender, RoutedEventArgs e) private void OnAddItem(object sender, RoutedEventArgs e)
@@ -600,6 +614,7 @@ public partial class SchedulePage : Page
RemoveButton.IsEnabled = Editable(index); RemoveButton.IsEnabled = Editable(index);
var onAir = !_working && playing && index >= 0 && index == current; var onAir = !_working && playing && index >= 0 && index == current;
EditItemButton.IsEnabled = (Editable(index) || onAir) && row!.Item.Kind != ScheduleItemKind.Song; EditItemButton.IsEnabled = (Editable(index) || onAir) && row!.Item.Kind != ScheduleItemKind.Song;
EndNowButton.IsEnabled = !_working && _expectPlaying != false && _controller.CurrentItem is not null;
var blocker = row switch var blocker = row switch
{ {
@@ -265,6 +265,32 @@ public sealed class ScheduleControllerTests : IDisposable
return (controller, started); return (controller, started);
} }
[Fact]
public async Task EndCurrentNow_EndsTheItemOnAirAndStartsTheNext()
{
var (controller, started) = await OnAirWithTheFirstNewsAsync();
_now = _now.AddMinutes(2);
var plan = controller.EndCurrentNow();
Assert.Equal(TimeSpan.FromMinutes(2), plan[0].Duration);
AssertContiguousFrom(plan, plan[0].Start);
Assert.Equal(_now, plan[1].Start);
Assert.True(await started.WaitAsync(TimeSpan.FromSeconds(5)));
Assert.Equal(1, controller.CurrentIndex);
controller.Stop();
}
[Fact]
public void EndCurrentNow_WithNothingOnAirThrows()
{
AddSongs();
var controller = Create();
controller.CreatePlan(1);
Assert.Throws<ScheduleException>(() => controller.EndCurrentNow());
}
[Fact] [Fact]
public async Task EditItem_ChangesTheItemOnAirButItCannotBeRemoved() public async Task EditItem_ChangesTheItemOnAirButItCannotBeRemoved()
{ {