fix(playback): harden offline source reporting
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user