Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix bluetooth resume from idle state re-initializing playback, use download green for Saved label

Nathan Poulson99ce5b053f51
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index 450eeea2..8030c08a 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -2488,6 +2488,23 @@ class AudioPlayerService extends ChangeNotifier {
}
// Re-activate audio session (needed after stop() releases it)
try { (await AudioSession.instance).setActive(true); } catch (_) {}
+ // If the player is idle (source was disposed), we need to fully re-initialize
+ // playback instead of just calling play() on an empty player.
+ if (_player?.processingState == ProcessingState.idle && _currentItemId != null && _api != null) {
+ debugPrint('[Player] Player is idle on resume - re-initializing playback for $_currentItemId');
+ playItem(
+ api: _api!,
+ itemId: _currentItemId!,
+ title: _currentTitle ?? '',
+ author: _currentAuthor ?? '',
+ coverUrl: _currentCoverUrl,
+ totalDuration: _totalDuration,
+ chapters: _chapters,
+ episodeId: _currentEpisodeId,
+ episodeTitle: _currentEpisodeTitle,
+ );
+ return;
+ }
_player?.play();
_logEvent(PlaybackEventType.play);
_onPlaybackStateChangedCallback?.call(true);
diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dart
index c6ee5142..ca6a58ab 100644
--- a/lib/widgets/absorbing_card.dart
+++ b/lib/widgets/absorbing_card.dart
@@ -574,11 +574,11 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
opacity: isDownloaded ? 1.0 : 0.0,
child: Row(mainAxisSize: MainAxisSize.min, children: [
Icon(Icons.download_done_rounded, size: 11,
- color: isDark ? Colors.white.withValues(alpha: 0.35) : cs.onSurface.withValues(alpha: 0.35)),
+ color: isDark ? Colors.greenAccent.withValues(alpha: 0.7) : Colors.green.shade700.withValues(alpha: 0.7)),
const SizedBox(width: 3),
Text('Saved', style: TextStyle(
fontSize: 10, fontWeight: FontWeight.w500,
- color: isDark ? Colors.white.withValues(alpha: 0.35) : cs.onSurface.withValues(alpha: 0.35),
+ color: isDark ? Colors.greenAccent.withValues(alpha: 0.7) : Colors.green.shade700.withValues(alpha: 0.7),
)),
]),
),