feat(stream): one-click Back on air — a new broadcast, honestly labelled (TASK 32·3)
The last resilience slice. When a drop ends the broadcast, YouTube cannot resume it, so the only way
back is a new one — and that is what the app now offers, in one click.
- `Services/BroadcastTitle.cs` — the resume marker is applied to the title the show was using, and any
existing marker is REPLACED rather than stacked ("Show (resumed)" → "Show (resumed 2)"), with the base
truncated so the whole title fits YouTube's 100-character limit. Otherwise a channel grows two
identically named videos and the creator has to explain it.
- `MainViewModel.BackOnAirCommand` — reuses the ordinary go-live path with the saved details and the
cached stream: new broadcast, new VOD, no dialog. It appears only after a drop ended the session and
the ordinary start button steps aside, so there is exactly one way forward.
- The running line goes red OFF AIR (not amber) in that state; the button reads "● Back on air".
Tests: `BackOnAirTests` — first re-air marks the title, a second drop counts instead of stacking, the
100-character limit holds, an empty title still works, and the post-drop state exposes exactly one
start affordance. FAST gate: 552 passed, 0 failed, 0 warnings.
TASK 32 is now complete: fragmented MP4, blip retry, poll-driven RECONNECTING, ingest pre-flight, Back
on air.
This commit is contained in:
@@ -34,6 +34,63 @@ public partial class MainViewModel
|
||||
|
||||
private bool _isReconnecting;
|
||||
|
||||
/// <summary>True after a drop ended the session with the broadcast gone: the show is over and the
|
||||
/// only honest action left is a new broadcast. Drives the red OFF AIR line and the
|
||||
/// "Back on air" button (TASK 32·3).</summary>
|
||||
public bool IsOffAirAfterDrop
|
||||
{
|
||||
get => _isOffAirAfterDrop;
|
||||
private set
|
||||
{
|
||||
if (!SetProperty(ref _isOffAirAfterDrop, value)) return;
|
||||
RaiseTopBarModes();
|
||||
OnPropertyChanged(nameof(ShowPrimaryStartButton));
|
||||
OnPropertyChanged(nameof(BackOnAirLabel));
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isOffAirAfterDrop;
|
||||
|
||||
public string BackOnAirLabel => "● Back on air";
|
||||
|
||||
private RelayCommand? _backOnAirCommand;
|
||||
|
||||
/// <summary>One click: build a new broadcast from the saved details and push — no dialog, and the
|
||||
/// title carries the resume marker so the channel shows what happened.</summary>
|
||||
public RelayCommand BackOnAirCommand =>
|
||||
_backOnAirCommand ??= new RelayCommand(_ => BackOnAir(), _ => IsOffAirAfterDrop && IsOffline);
|
||||
|
||||
/// <summary>How many times this session has been resumed — the title marker counts.</summary>
|
||||
private int _resumeCount;
|
||||
|
||||
/// <summary>The title the dropped show was using, kept so the resumed broadcast is named after it
|
||||
/// rather than after whatever the form happens to hold now.</summary>
|
||||
private string? _lastLiveTitle;
|
||||
|
||||
private void BackOnAir()
|
||||
{
|
||||
if (!IsOffAirAfterDrop) return;
|
||||
|
||||
_resumeCount++;
|
||||
StreamTitle = BroadcastTitle.ForResume(_lastLiveTitle ?? StreamTitle, _resumeCount);
|
||||
WindowTitle = $"{StreamTitle} — LlamaCasty";
|
||||
|
||||
// Clear the state BEFORE starting: the go-live path reuses the primary-button gate, and a
|
||||
// session that starts while this flag is set would show two ways to start at once.
|
||||
IsOffAirAfterDrop = false;
|
||||
|
||||
AppLog.Write($"RECONNECT: back on air as a new broadcast — '{StreamTitle}'");
|
||||
OnAirPillOn = true;
|
||||
StartStreamingSession(alsoRecord: false); // the ordinary path: new broadcast, same cached stream
|
||||
}
|
||||
|
||||
/// <summary>Test seam: puts the view-model in the post-drop state without a live session.</summary>
|
||||
internal void MarkOffAirAfterDropForTest(string? title)
|
||||
{
|
||||
_lastLiveTitle = title;
|
||||
IsOffAirAfterDrop = true;
|
||||
}
|
||||
|
||||
/// <summary>The attempt currently in flight (0 when idle).</summary>
|
||||
public int ReconnectAttempt
|
||||
{
|
||||
@@ -184,9 +241,14 @@ public partial class MainViewModel
|
||||
default:
|
||||
// Gave up, or the broadcast was already complete: this session is over. The alert
|
||||
// stack keeps the reason; the normal stop path clears pills, audio and recording.
|
||||
// Then the honest next step is offered as one click — a NEW broadcast (TASK 32·3),
|
||||
// which is the only way back on air once YouTube has completed this one.
|
||||
AppLog.Write("RECONNECT: session ended — the broadcast could not be recovered",
|
||||
AppLogMessageType.Error, AppLogErrorClass.Class1);
|
||||
var droppedTitle = StreamTitle;
|
||||
StopStream();
|
||||
MarkOffAirAfterDropForTest(null);
|
||||
_lastLiveTitle = droppedTitle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user