Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Keep audio playing on library switch when Merge Libraries is enabled

Nathan Poulson3fb79b0b213e
diff --git a/lib/providers/library_provider.dart b/lib/providers/library_provider.dart
index 051da222..0d54519f 100644
--- a/lib/providers/library_provider.dart
+++ b/lib/providers/library_provider.dart
@@ -259,17 +259,22 @@ class LibraryProvider extends ChangeNotifier
}
Future<void> selectLibrary(String libraryId) async {
- final wasPlaying = AudioPlayerService().isPlaying;
- final wasCasting = ChromecastService().isPlaying;
-
- // Stop playback if something is playing from the old library
- if (wasPlaying) {
- debugPrint('[Library] Stopping playback on library switch');
- await AudioPlayerService().stop();
- }
- if (wasCasting) {
- debugPrint('[Library] Stopping cast on library switch');
- ChromecastService().stopCasting();
+ // When Merge Libraries is on, the absorbing card stays visible across
+ // libraries so the user can still control playback. Only stop on switch
+ // when merge is off, otherwise the player would be unreachable from the
+ // new library.
+ final merged = await PlayerSettings.getMergeAbsorbingLibraries();
+ if (!merged) {
+ final wasPlaying = AudioPlayerService().isPlaying;
+ final wasCasting = ChromecastService().isPlaying;
+ if (wasPlaying) {
+ debugPrint('[Library] Stopping playback on library switch');
+ await AudioPlayerService().stop();
+ }
+ if (wasCasting) {
+ debugPrint('[Library] Stopping cast on library switch');
+ ChromecastService().stopCasting();
+ }
}
_selectedLibraryId = libraryId;