fix(playback): harden offline source reporting

This commit is contained in:
edde746
2026-05-29 19:55:01 +02:00
parent 7501f461b9
commit d93ea9813f
34 changed files with 739 additions and 273 deletions
@@ -74,6 +74,8 @@ class PlaybackProgressTracker {
/// Whether the final stopped progress event was already emitted locally.
bool _stopProgressNotified = false;
Future<void>? _stoppedProgressFuture;
Duration? _lastProgressNotifiedPosition;
static const Duration _progressNotifyDelta = Duration(seconds: 30);
@@ -162,6 +164,20 @@ class PlaybackProgressTracker {
await _sendProgress(state, positionOverride: positionOverride);
}
Future<void> sendStoppedProgressOnce({Duration? positionOverride}) {
final existing = _stoppedProgressFuture;
if (existing != null) return existing;
final future = sendProgress('stopped', positionOverride: positionOverride);
_stoppedProgressFuture = future;
return future;
}
void resumeAfterStoppedReport() {
_stoppedProgressFuture = null;
_stopProgressNotified = false;
_reportSession?.resetAfterStop();
}
Future<void> _sendProgress(String state, {Duration? positionOverride}) async {
Duration? attemptedPosition;
Duration? attemptedDuration;