A cross platform Audiobookshelf client for Android and iOS
Dart
Fix the CarPlay speed icon not updating when you change speed
Barnabas1b58fd6aa5a8
diff --git a/lib/services/carplay_service.dart b/lib/services/carplay_service.dartindex e965186d..f94f5ddc 100644--- a/lib/services/carplay_service.dart+++ b/lib/services/carplay_service.dart@@ -22,7 +22,6 @@ class CarPlayService {/// only on CPNowPlayingTemplate, so the iOS lock screen is never affected.static const _nowPlayingChannel = MethodChannel('com.absorb.carplay');- bool _connected = false;double _lastPushedSpeed = -1;bool _bannerShowing = false;Timer? _bannerDismissTimer;@@ -103,13 +102,11 @@ class CarPlayService {void _onConnectionChange(ConnectionStatusTypes status) {debugPrint('[CarPlay] Connection status: $status');if (status == ConnectionStatusTypes.disconnected) {- _connected = false;_rootTemplate = null;_lastRootBuilt = null;return;}if (status != ConnectionStatusTypes.connected) return;- _connected = true;// Guard duplicate `connected` events that iOS fires in quick succession.final now = DateTime.now();@@ -244,10 +241,13 @@ class CarPlayService {}}- /// Refresh the CarPlay speed button when the rate changes anywhere. Cheap:- /// short-circuits when not connected or when the speed hasn't moved.+ /// Refresh the CarPlay speed button when the rate changes anywhere. No+ /// "connected" gate on purpose: on a cold CarPlay launch the connected event+ /// fires before our listener registers and is missed, so that flag can stay+ /// false the whole session and would freeze the badge at its initial value.+ /// The speed-diff check keeps this cheap; re-pushing while disconnected just+ /// primes the shared Now Playing template, which is harmless.void _onPlayerChanged() {- if (!_connected) return;final speed = AudioPlayerService().speed;if ((speed - _lastPushedSpeed).abs() < 0.001) return;_configureNowPlayingButtons();diff --git a/pubspec.yaml b/pubspec.yamlindex e180b119..810bec99 100644--- a/pubspec.yaml+++ b/pubspec.yaml@@ -1,7 +1,7 @@name: absorbdescription: An Audiobookshelf Clientpublish_to: 'none'-version: 1.8.96+165+version: 1.8.96+166environment:sdk: '>=3.1.0 <4.0.0'