Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix progress bar freezing after seek

Nathan Poulson593e87f54397
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index 80bb7273..e93ead50 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -735,7 +735,7 @@ class AudioPlayerService extends ChangeNotifier {
double? _lastSeekTargetSeconds;
DateTime? _lastSeekTime;
- /// If a seek happened within the last 2 seconds, returns the seek target.
+ /// If a seek happened recently, returns the seek target.
/// Otherwise returns null (use the stream position).
double? get activeSeekTarget {
if (_lastSeekTargetSeconds == null || _lastSeekTime == null) return null;
@@ -748,6 +748,12 @@ class AudioPlayerService extends ChangeNotifier {
return _lastSeekTargetSeconds;
}
+ /// Clear the seek target once the stream has caught up.
+ void clearSeekTarget() {
+ _lastSeekTargetSeconds = null;
+ _lastSeekTime = null;
+ }
+
final _progressSync = ProgressSyncService();
final _downloadService = DownloadService();
final _history = PlaybackHistoryService();
diff --git a/lib/widgets/card_progress_bar.dart b/lib/widgets/card_progress_bar.dart
index 056a4909..b59c3404 100644
--- a/lib/widgets/card_progress_bar.dart
+++ b/lib/widgets/card_progress_bar.dart
@@ -115,6 +115,9 @@ class _CardDualProgressBarState extends State<CardDualProgressBar> with TickerPr
_lastPosTime = DateTime.now();
_currentSpeed = widget.player.speed;
_isPlaying = widget.player.isPlaying;
+ // Stream has caught up — clear the seek target so subsequent
+ // position updates flow through normally without filtering.
+ widget.player.clearSeekTarget();
return;
}
// Reject transient values far from the seek target