A cross platform Audiobookshelf client for Android and iOS
Dart
Fix play button showing stale state after app resume
Nathan Poulson22a6318fb9f0
diff --git a/lib/widgets/card_playback_controls.dart b/lib/widgets/card_playback_controls.dartindex c77e75a7..70f15280 100644--- a/lib/widgets/card_playback_controls.dart+++ b/lib/widgets/card_playback_controls.dart@@ -175,8 +175,13 @@ class _CardPlaybackControlsState extends State<CardPlaybackControls> with Singlereturn StreamBuilder<PlayerState>(stream: widget.isActive ? widget.player.playerStateStream : const Stream.empty(),builder: (_, snapshot) {- final isPlaying = widget.isActive && (snapshot.data?.playing ?? false);- final isLoading = widget.isActive && (snapshot.data?.processingState == ProcessingState.loading || snapshot.data?.processingState == ProcessingState.buffering);+ // Use synchronous player state as fallback — broadcast streams don't+ // replay the last event, so after an app-resume the snapshot can be+ // null even though audio is actively playing.+ final playing = snapshot.data?.playing ?? widget.player.isPlaying;+ final processingState = snapshot.data?.processingState ?? ProcessingState.ready;+ final isPlaying = widget.isActive && playing;+ final isLoading = widget.isActive && (processingState == ProcessingState.loading || processingState == ProcessingState.buffering);if (isPlaying) {_playPauseController.forward();