A cross platform Audiobookshelf client for Android and iOS
Dart
Each library can set its own default speed
Barnabas157d98a76b0e
diff --git a/lib/providers/_lp_state.dart b/lib/providers/_lp_state.dartindex 8a7e3a22..07d393f5 100644--- a/lib/providers/_lp_state.dart+++ b/lib/providers/_lp_state.dart@@ -155,6 +155,20 @@ mixin _StateMixin on ChangeNotifier {List<String> get absorbingBookIds => _absorbingBookIds;Map<String, Map<String, dynamic>> get absorbingItemCache =>_absorbingItemCache;++ /// The library an item belongs to, as far as this phone knows: the card+ /// cache, then download metadata, then whatever is playing.+ String? libraryIdOf(String itemId, {String? episodeId}) {+ final key = episodeId != null ? '$itemId-$episodeId' : itemId;+ final cached = _absorbingItemCache[key]?['libraryId'] as String? ??+ _absorbingItemCache[itemId]?['libraryId'] as String?;+ if (cached != null && cached.isNotEmpty) return cached;+ final downloaded = DownloadService().getInfo(key).libraryId;+ if (downloaded != null && downloaded.isNotEmpty) return downloaded;+ final player = AudioPlayerService();+ if (player.currentItemId == itemId) return player.currentLibraryId;+ return null;+ }String? get freshQueuedFrontKey => _freshQueuedFrontKey;Map<String, dynamic>? get selectedLibrary {diff --git a/lib/screens/bookmarks_screen.dart b/lib/screens/bookmarks_screen.dartindex a3b6de53..b3ccd2be 100644--- a/lib/screens/bookmarks_screen.dart+++ b/lib/screens/bookmarks_screen.dart@@ -55,6 +55,7 @@ class _BookmarksScreenState extends State<BookmarksScreen>// speed-adjusted-time setting at that book's own speed.final Map<String, double> _bookSpeeds = {};double _defaultSpeed = 1.0;+ final Map<String, double> _librarySpeeds = {};final TextEditingController _searchCtl = TextEditingController();String _query = '';// Books opened on the bookmarks tab; all start folded. Kept while the screen is open.@@ -181,6 +182,14 @@ class _BookmarksScreenState extends State<BookmarksScreen>Future<void> _loadBookSpeeds() async {_defaultSpeed = await PlayerSettings.getDefaultSpeed();+ if (mounted) {+ for (final library in context.read<LibraryProvider>().libraries) {+ final id = library['id'] as String?;+ if (id == null) continue;+ final override = await PlayerSettings.getSpeedOverride(id);+ if (override != null) _librarySpeeds[id] = override;+ }+ }var changed = false;for (final key in _allBookmarks.keys) {final itemId = splitEpisodeKey(key).itemId;@@ -198,10 +207,14 @@ class _BookmarksScreenState extends State<BookmarksScreen>if (!_speedAdjustedTime) return 1.0;// Speed is saved per book, and a podcast's per-show, so an episode key has// to come apart before either lookup.- final itemId = splitEpisodeKey(key).itemId;+ final parts = splitEpisodeKey(key);+ final itemId = parts.itemId;final player = AudioPlayerService();if (player.currentItemId == itemId) return player.speed;- return _bookSpeeds[itemId] ?? _defaultSpeed;+ final libraryId = context+ .read<LibraryProvider>()+ .libraryIdOf(itemId, episodeId: parts.episodeId);+ return _bookSpeeds[itemId] ?? _librarySpeeds[libraryId] ?? _defaultSpeed;}Future<void> _loadSort() async {diff --git a/lib/screens/car_mode_screen.dart b/lib/screens/car_mode_screen.dartindex 1a1f0f90..5c84b921 100644--- a/lib/screens/car_mode_screen.dart+++ b/lib/screens/car_mode_screen.dart@@ -498,6 +498,7 @@ class _CarModeScreenState extends State<CarModeScreen>player: player,accent: Colors.white,itemId: player.currentItemId,+ libraryId: player.currentLibraryId,),);},diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex dfd1421e..2634230d 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -315,6 +315,8 @@ class SettingsScreenState extends State<SettingsScreen> {bool _curLibSkipOverride = false;int _curLibSkipForward = 30;int _curLibSkipBack = 10;+ bool _curLibSpeedOverride = false;+ double _curLibSpeed = 1.0;bool _coverPlayButton = false;String _cardBackground = 'blurred';double _progressTextScale = 1.0;@@ -1514,8 +1516,11 @@ class SettingsScreenState extends State<SettingsScreen> {final shape = await PlayerSettings.getRectangleCoversOverride(libraryId);final subtitles = await PlayerSettings.getShowSubtitlesOverride(libraryId);final skip = await PlayerSettings.getSkipOverride(libraryId);+ final speed = await PlayerSettings.getSpeedOverride(libraryId);if (mounted) setState(() {_curLibId = libraryId;+ _curLibSpeedOverride = speed != null;+ _curLibSpeed = speed ?? _defaultSpeed;_curLibCoverShape = shape ?? 'default';_curLibSubtitles = subtitles ?? 'default';_curLibSkipOverride = skip != null;@@ -3187,6 +3192,7 @@ class SettingsScreenState extends State<SettingsScreen> {),),const Divider(height: 1, indent: 16, endIndent: 16),+ const Divider(height: 1, indent: 16, endIndent: 16),ListTile(leading: Icon(Icons.refresh_rounded, color: cs.onSurfaceVariant),title: Text(l.resetSpeedPresets),@@ -4567,6 +4573,43 @@ class SettingsScreenState extends State<SettingsScreen> {} : null,),],+ const Divider(height: 1, indent: 16, endIndent: 16),+ SwitchListTile(+ title: Text(l.currentLibrarySpeedOverride),+ subtitle: Text(+ _curLibSpeedOverride+ ? l.currentLibrarySpeedOverrideOnSubtitle+ : l.currentLibrarySpeedOverrideOffSubtitle,+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),+ ),+ value: _curLibSpeedOverride,+ onChanged: _loaded ? (v) {+ setState(() => _curLibSpeedOverride = v);+ PlayerSettings.setSpeedOverride(_curLibId!, v ? _curLibSpeed : null);+ } : null,+ ),+ if (_curLibSpeedOverride) ...[+ Padding(+ padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ Text(l.currentLibrarySpeed, style: tt.bodyMedium?.copyWith(color: cs.onSurfaceVariant)),+ Text(l.speedValue(_curLibSpeed.toStringAsFixed(2)), style: tt.bodyMedium?.copyWith(+ fontWeight: FontWeight.w600, color: cs.primary)),+ ],+ ),+ ),+ AbsorbSlider(+ value: _curLibSpeed,+ min: 0.5, max: 5.0, divisions: 90,+ onChanged: _loaded ? (v) {+ final s = (v * 20).round() / 20.0;+ setState(() => _curLibSpeed = s);+ PlayerSettings.setSpeedOverride(_curLibId!, s);+ } : null,+ ),+ ],],],),diff --git a/lib/screens/settings_search_index.dart b/lib/screens/settings_search_index.dartindex 4bd4cf14..66129284 100644--- a/lib/screens/settings_search_index.dart+++ b/lib/screens/settings_search_index.dart@@ -134,6 +134,7 @@ List<SettingSearchEntry> settingsSearchEntries(BuildContext context) {SettingSearchEntry('Library', l.sectionLibrary, l.coverShapeLabel, [l.coverShapeDefault, l.coverShapeSquare, l.coverShapeRectangle]),SettingSearchEntry('Library', l.sectionLibrary, l.subtitleVisibilityLabel, [l.subtitleVisibilityDefault, l.subtitleVisibilityShow, l.subtitleVisibilityHide]),SettingSearchEntry('Library', l.sectionLibrary, l.currentLibrarySkipOverride, [l.currentLibrarySkipOverrideOnSubtitle, l.currentLibrarySkipOverrideOffSubtitle]),+ SettingSearchEntry('Library', l.sectionLibrary, l.currentLibrarySpeedOverride, [l.currentLibrarySpeedOverrideOnSubtitle, l.currentLibrarySpeedOverrideOffSubtitle]),SettingSearchEntry('Library', l.sectionLibrary, l.currentLibrarySkipBack, const []),SettingSearchEntry('Library', l.sectionLibrary, l.currentLibrarySkipForward, const []),diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dartindex 6b03d8f7..82d7b330 100644--- a/lib/services/audio_player_service.dart+++ b/lib/services/audio_player_service.dart@@ -4636,7 +4636,8 @@ class AudioPlayerService extends ChangeNotifier {if (totalDuration > 0 && startTime >= totalDuration - 1.0) startTime = 0;final speedKey = _currentItemId ?? itemId;final bookSpeed = await PlayerSettings.getBookSpeed(speedKey);- final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();+ final speed = bookSpeed ??+ await PlayerSettings.defaultSpeedFor(libraryId: _currentLibraryId);startTime = await _sessionStartRewound(startTime,forceStartTime: forceStartTime,@@ -4886,7 +4887,8 @@ class AudioPlayerService extends ChangeNotifier {if (totalDuration > 0 && startTime >= totalDuration - 1.0) startTime = 0;final bookSpeed = await PlayerSettings.getBookSpeed(itemId);- final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();+ final speed = bookSpeed ??+ await PlayerSettings.defaultSpeedFor(libraryId: _currentLibraryId);startTime = await _sessionStartRewound(startTime,forceStartTime: forceStartTime,@@ -5350,7 +5352,8 @@ class AudioPlayerService extends ChangeNotifier {// If the saved position is at (or past) the end, restart from the beginningif (totalDuration > 0 && startTime >= totalDuration - 1.0) startTime = 0;final bookSpeed = await PlayerSettings.getBookSpeed(itemId);- final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();+ final speed = bookSpeed ??+ await PlayerSettings.defaultSpeedFor(libraryId: _currentLibraryId);startTime = await _sessionStartRewound(startTime,forceStartTime: forceStartTime,@@ -5595,7 +5598,8 @@ class AudioPlayerService extends ChangeNotifier {final initChapter = _initChapterInfo(startTime);// Speed before _pushMediaItem - the pushed duration is speed-adjusted.final bookSpeed = await PlayerSettings.getBookSpeed(itemId);- final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();+ final speed = bookSpeed ??+ await PlayerSettings.defaultSpeedFor(libraryId: _currentLibraryId);await _player!.setSpeed(speed);_pushMediaItem(itemId,diff --git a/lib/services/backup_service.dart b/lib/services/backup_service.dartindex 265d5e95..79a246c0 100644--- a/lib/services/backup_service.dart+++ b/lib/services/backup_service.dart@@ -276,13 +276,14 @@ class BackupService {if (!key.startsWith(fullPrefix)) continue;final libraryId = key.substring(fullPrefix.length);final value = prefs.get(key);- if (value is! String && value is! int) continue;+ if (value is! String && value is! int && value is! double) continue;librarySettings.putIfAbsent(libraryId, () => {})[field] = value;}}collectLibrarySetting('rectangleCovers_', 'coverShape');collectLibrarySetting('skipOverrideForward_', 'skipForward');collectLibrarySetting('skipOverrideBack_', 'skipBack');+ collectLibrarySetting('speedOverride_', 'speed');// Per-item metadata overrides (scoped, keyed by itemId)final metadataOverrides = <String, String>{};@@ -921,6 +922,7 @@ class BackupService {'${scopePrefix}rectangleCovers_','${scopePrefix}skipOverrideForward_','${scopePrefix}skipOverrideBack_',+ '${scopePrefix}speedOverride_',];final oldKeys = prefs.getKeys()@@ -948,6 +950,8 @@ class BackupService {back: skipBack,);}+ final speed = (settings['speed'] as num?)?.toDouble();+ if (speed != null) await PlayerSettings.setSpeedOverride(libraryId, speed);}}diff --git a/lib/services/chromecast_service.dart b/lib/services/chromecast_service.dartindex 81034f0a..9f54b84e 100644--- a/lib/services/chromecast_service.dart+++ b/lib/services/chromecast_service.dart@@ -592,6 +592,7 @@ class ChromecastService extends ChangeNotifier {required String? coverUrl, required double totalDuration,required List<dynamic> chapters, double startTime = 0,String? episodeId,+ String? libraryId,}) async {debugPrint('[Cast] >>> castItem() — "$title" (id: $itemId)');debugPrint('[Cast] isConnected=$isConnected, connectionState=$_connectionState');@@ -667,7 +668,8 @@ class ChromecastService extends ChangeNotifier {// Load per-book speed (or global default)final bookSpeed = await PlayerSettings.getBookSpeed(itemId);- final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();+ final speed = bookSpeed ??+ await PlayerSettings.defaultSpeedFor(libraryId: libraryId);_castSpeed = speed;debugPrint('[Cast] Starting from position: ${startTime}s, speed: ${speed}x');diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dartindex fe2bcd64..0817ea53 100644--- a/lib/services/player_settings.dart+++ b/lib/services/player_settings.dart@@ -144,6 +144,29 @@ class PlayerSettings {static Future<void> setDefaultSpeed(double speed) =>_set('defaultSpeed', speed);+ /// Per-library default speed: a library (podcasts, say) can start its items+ /// at its own speed instead of the global default. null = no override.+ static Future<double?> getSpeedOverride(String libraryId) =>+ ScopedPrefs.getDouble('speedOverride_$libraryId');++ static Future<void> setSpeedOverride(String libraryId, double? speed) async {+ if (speed == null) {+ await ScopedPrefs.remove('speedOverride_$libraryId');+ } else {+ await ScopedPrefs.setDouble('speedOverride_$libraryId', speed);+ }+ _notify();+ }++ /// The speed a book or episode starts at before it has one of its own.+ static Future<double> defaultSpeedFor({String? libraryId}) async {+ if (libraryId != null && libraryId.isNotEmpty) {+ final override = await getSpeedOverride(libraryId);+ if (override != null) return override;+ }+ return getDefaultSpeed();+ }+static const List<double> defaultSpeedPresets = [0.75,1.0,diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dartindex 41889311..1cd23653 100644--- a/lib/widgets/absorbing_card.dart+++ b/lib/widgets/absorbing_card.dart@@ -343,7 +343,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCliFuture<void> _loadSavedSpeed() async {final bookSpeed = await PlayerSettings.getBookSpeed(_itemId);- final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();+ final speed = bookSpeed ?? await PlayerSettings.defaultSpeedFor(libraryId: _resolveLibraryId());if (mounted && speed != _savedSpeed) setState(() => _savedSpeed = speed);}@@ -1184,7 +1184,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveClifinal scrubberBar = Padding(padding: const EdgeInsets.symmetric(horizontal: 20),- child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: (_isPodcastEpisode && _chapters.isEmpty) ? 0.0 : progress, staticDuration: (_isPodcastEpisode && _chapters.isEmpty) ? widget.player.totalDuration : _effectiveDuration, chapters: _chapters, showBookBar: false, showChapterBar: true, chapterName: (_isPodcastEpisode && _chapters.isEmpty) ? (widget.player.currentEpisodeTitle ?? widget.player.currentTitle ?? _title) : (_episodeId != null && !_isActive ? (_recentEpisode?['title'] as String? ?? _title) : (_chapters.isEmpty ? _title : _chapterName(chapterIdx))), chapterIndex: chapterIdx, totalChapters: totalChapters, itemId: _itemId, compact: compact),+ child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: (_isPodcastEpisode && _chapters.isEmpty) ? 0.0 : progress, staticDuration: (_isPodcastEpisode && _chapters.isEmpty) ? widget.player.totalDuration : _effectiveDuration, chapters: _chapters, showBookBar: false, showChapterBar: true, chapterName: (_isPodcastEpisode && _chapters.isEmpty) ? (widget.player.currentEpisodeTitle ?? widget.player.currentTitle ?? _title) : (_episodeId != null && !_isActive ? (_recentEpisode?['title'] as String? ?? _title) : (_chapters.isEmpty ? _title : _chapterName(chapterIdx))), chapterIndex: chapterIdx, totalChapters: totalChapters, itemId: _itemId, compact: compact, libraryId: _resolveLibraryId()),);final controlsRow = Padding(@@ -1293,6 +1293,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCliitemId: _itemId,compact: compact,showBookPercentage: true,+ libraryId: _resolveLibraryId(),),),);@@ -1600,6 +1601,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCliitem: widget.item,itemId: _itemId,episodeId: _episodeId,+ libraryId: _resolveLibraryId(),isPodcastEpisode: _isPodcastEpisode,title: _title,author: _author,diff --git a/lib/widgets/bookmark_detail_dialog.dart b/lib/widgets/bookmark_detail_dialog.dartindex 27b0339c..082ff657 100644--- a/lib/widgets/bookmark_detail_dialog.dart+++ b/lib/widgets/bookmark_detail_dialog.dart@@ -129,7 +129,9 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {player.currentEpisodeId == widget.episodeId)? player.speed: (await PlayerSettings.getBookSpeed(widget.itemId) ??- await PlayerSettings.getDefaultSpeed());+ await PlayerSettings.defaultSpeedFor(+ libraryId: context.read<LibraryProvider>().libraryIdOf(+ widget.itemId, episodeId: widget.episodeId)));if (mounted && speed > 0 && speed != _displaySpeed) {setState(() => _displaySpeed = speed);}diff --git a/lib/widgets/card_buttons.dart b/lib/widgets/card_buttons.dartindex 9976c508..a9dcb1df 100644--- a/lib/widgets/card_buttons.dart+++ b/lib/widgets/card_buttons.dart@@ -606,7 +606,8 @@ class CardSpeedButtonInline extends StatefulWidget {final bool compact;final bool iconsOnly;final String? itemId;- const CardSpeedButtonInline({super.key, required this.player, required this.accent, required this.isActive, this.large = false, this.compact = false, this.iconsOnly = false, this.itemId});+ final String? libraryId;+ const CardSpeedButtonInline({super.key, required this.player, required this.accent, required this.isActive, this.large = false, this.compact = false, this.iconsOnly = false, this.itemId, this.libraryId});@override State<CardSpeedButtonInline> createState() => _CardSpeedButtonInlineState();}@@ -630,7 +631,7 @@ class _CardSpeedButtonInlineState extends State<CardSpeedButtonInline> {Future<void> _loadSavedSpeed() async {if (widget.itemId == null) return;final bookSpeed = await PlayerSettings.getBookSpeed(widget.itemId!);- final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();+ final speed = bookSpeed ?? await PlayerSettings.defaultSpeedFor(libraryId: widget.libraryId);if (mounted && speed != _savedSpeed) setState(() => _savedSpeed = speed);}@@ -671,7 +672,7 @@ class _CardSpeedButtonInlineState extends State<CardSpeedButtonInline> {onTap: () {showAdaptiveActionMenu(context: context, backgroundColor: Colors.transparent,useSafeArea: true,- builder: (ctx) => CardSpeedSheet(player: widget.player, accent: widget.accent, itemId: widget.itemId));+ builder: (ctx) => CardSpeedSheet(player: widget.player, accent: widget.accent, itemId: widget.itemId, libraryId: widget.libraryId));},child: Container(height: h,@@ -691,8 +692,8 @@ class _CardSpeedButtonInlineState extends State<CardSpeedButtonInline> {// ─── SPEED SHEET ─────────────────────────────────────────────class CardSpeedSheet extends StatefulWidget {- final AudioPlayerService player; final Color accent; final String? itemId;- const CardSpeedSheet({super.key, required this.player, required this.accent, this.itemId});+ final AudioPlayerService player; final Color accent; final String? itemId; final String? libraryId;+ const CardSpeedSheet({super.key, required this.player, required this.accent, this.itemId, this.libraryId});@override State<CardSpeedSheet> createState() => _CardSpeedSheetState();}@@ -739,7 +740,7 @@ class _CardSpeedSheetState extends State<CardSpeedSheet> {Future<void> _loadSavedSpeed() async {if (widget.itemId == null) return;final bookSpeed = await PlayerSettings.getBookSpeed(widget.itemId!);- final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();+ final speed = bookSpeed ?? await PlayerSettings.defaultSpeedFor(libraryId: widget.libraryId);if (mounted) setState(() => _speed = (speed * 20).round() / 20.0);}void _setSpeed(double v) {@@ -869,7 +870,9 @@ class _SimpleBookmarkSheetState extends State<SimpleBookmarkSheet> {if (mounted && v != _speedAdjustedTime) setState(() => _speedAdjustedTime = v);});PlayerSettings.getBookSpeed(widget.itemId).then((s) async {- final speed = s ?? await PlayerSettings.getDefaultSpeed();+ final speed = s ??+ await PlayerSettings.defaultSpeedFor(+ libraryId: context.read<LibraryProvider>().libraryIdOf(widget.itemId, episodeId: widget.episodeId));if (mounted && speed != _savedSpeed) setState(() => _savedSpeed = speed);});}@@ -1629,6 +1632,7 @@ class CardActionDelegate {final Map<String, dynamic> item;final String itemId;final String? episodeId;+ final String? libraryId;final bool isPodcastEpisode;final String title;final String? author;@@ -1664,6 +1668,7 @@ class CardActionDelegate {required this.item,required this.itemId,this.episodeId,+ this.libraryId,this.isPodcastEpisode = false,required this.title,this.author,@@ -1959,7 +1964,7 @@ class CardActionDelegate {return CardWideButton(icon: Icons.speed_rounded, label: l.speed,accent: accent, isActive: isPlaybackActive, large: large, compact: compact, iconsOnly: iconsOnly,- child: CardSpeedButtonInline(player: player, accent: accent, isActive: isActive, large: large, compact: compact, iconsOnly: iconsOnly, itemId: itemId),+ child: CardSpeedButtonInline(player: player, accent: accent, isActive: isActive, large: large, compact: compact, iconsOnly: iconsOnly, itemId: itemId, libraryId: libraryId),);case 'sleep':return CardWideButton(@@ -2136,7 +2141,7 @@ class CardActionDelegate {onTap: () {Navigator.pop(ctx);showAdaptiveActionMenu(context: context, backgroundColor: Colors.transparent, useSafeArea: true,- builder: (_) => CardSpeedSheet(player: player, accent: accent, itemId: itemId));+ builder: (_) => CardSpeedSheet(player: player, accent: accent, itemId: itemId, libraryId: libraryId));},);case 'sleep':@@ -2396,6 +2401,7 @@ class CardActionDelegate {api: api, itemId: itemId, title: title, author: author ?? '',coverUrl: coverUrl, totalDuration: duration, chapters: chapters,episodeId: episodeId ?? player.currentEpisodeId,+ libraryId: libraryId,);}} else {@@ -2595,7 +2601,9 @@ class _PlaybackHistorySheetBodyState extends State<_PlaybackHistoryBody>if (mounted && v != _speedAdjustedTime) setState(() => _speedAdjustedTime = v);});PlayerSettings.getBookSpeed(widget.itemId).then((s) async {- final speed = s ?? await PlayerSettings.getDefaultSpeed();+ final speed = s ??+ await PlayerSettings.defaultSpeedFor(+ libraryId: context.read<LibraryProvider>().libraryIdOf(widget.itemId, episodeId: widget.episodeId));if (mounted && speed != _savedSpeed) setState(() => _savedSpeed = speed);});_selectedTab = widget.initialTab.index;diff --git a/lib/widgets/card_progress_bar.dart b/lib/widgets/card_progress_bar.dartindex 0f8a66a7..679ed2b3 100644--- a/lib/widgets/card_progress_bar.dart+++ b/lib/widgets/card_progress_bar.dart@@ -29,7 +29,8 @@ class CardDualProgressBar extends StatefulWidget {/// (between elapsed and remaining) instead of the caller stacking a/// separate percent line above - saves a row on the full screen player.final bool showCenterPercent;- const CardDualProgressBar({super.key, required this.player, required this.accent, required this.isActive, required this.staticProgress, required this.staticDuration, required this.chapters, this.showBookBar = true, this.showChapterBar = true, this.chapterName, this.chapterIndex = 0, this.totalChapters = 0, this.itemId, this.compact = false, this.showBookPercentage = false, this.showCenterPercent = false});+ final String? libraryId;+ const CardDualProgressBar({super.key, required this.player, required this.accent, required this.isActive, required this.staticProgress, required this.staticDuration, required this.chapters, this.showBookBar = true, this.showChapterBar = true, this.chapterName, this.chapterIndex = 0, this.totalChapters = 0, this.itemId, this.compact = false, this.showBookPercentage = false, this.showCenterPercent = false, this.libraryId});@override State<CardDualProgressBar> createState() => _CardDualProgressBarState();}@@ -82,7 +83,8 @@ class _CardDualProgressBarState extends State<CardDualProgressBar> with WidgetsBFuture<void> _loadSavedSpeed() async {final itemId = widget.itemId;final bookSpeed = itemId != null ? await PlayerSettings.getBookSpeed(itemId) : null;- final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();+ final speed = bookSpeed ??+ await PlayerSettings.defaultSpeedFor(libraryId: widget.libraryId);if (mounted && speed != _savedSpeed) setState(() => _savedSpeed = speed);}diff --git a/lib/widgets/episode_detail_sheet.dart b/lib/widgets/episode_detail_sheet.dartindex 55e360ff..e073311f 100644--- a/lib/widgets/episode_detail_sheet.dart+++ b/lib/widgets/episode_detail_sheet.dart@@ -160,6 +160,7 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {api: api, itemId: _itemId, title: _episodeTitle, author: _showTitle,coverUrl: api.getCoverUrl(_itemId), totalDuration: _duration, chapters: _chapters,episodeId: _episodeId,+ libraryId: widget.podcastItem['libraryId'] as String?,);if (mounted) Navigator.of(context, rootNavigator: true).popUntil((route) => route.isFirst);return;diff --git a/lib/widgets/episode_list_sheet.dart b/lib/widgets/episode_list_sheet.dartindex 091383f1..209a5a26 100644--- a/lib/widgets/episode_list_sheet.dart+++ b/lib/widgets/episode_list_sheet.dart@@ -503,6 +503,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {totalDuration: duration,chapters: chapters,episodeId: episodeId,+ libraryId: _podcastItem['libraryId'] as String?,);if (mounted) Navigator.of(context, rootNavigator: true).popUntil((route) => route.isFirst);return;diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dartindex 752c05e9..358fd95c 100644--- a/lib/widgets/expanded_card.dart+++ b/lib/widgets/expanded_card.dart@@ -749,7 +749,7 @@ class _ExpandedCardState extends State<ExpandedCard> {final bookProgressBar = Padding(padding: const EdgeInsets.symmetric(horizontal: 20),- child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: progress, staticDuration: _effectiveDuration, chapters: _chapters, showBookBar: showBookBar, showChapterBar: false, itemId: _itemId, showCenterPercent: true),+ child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: progress, staticDuration: _effectiveDuration, chapters: _chapters, showBookBar: showBookBar, showChapterBar: false, itemId: _itemId, showCenterPercent: true, libraryId: _resolveLibraryId()),);final coverArea = Padding(@@ -951,7 +951,7 @@ class _ExpandedCardState extends State<ExpandedCard> {final chapterScrubber = Padding(padding: const EdgeInsets.symmetric(horizontal: 20),- child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: (_isPodcastEpisode && _chapters.isEmpty) ? 0.0 : progress, staticDuration: (_isPodcastEpisode && _chapters.isEmpty) ? widget.player.totalDuration : _effectiveDuration, chapters: _chapters, showBookBar: false, showChapterBar: true, chapterName: (_isPodcastEpisode && _chapters.isEmpty) ? (widget.player.currentEpisodeTitle ?? widget.player.currentTitle ?? _title) : (_episodeId != null && !_isActive ? (_recentEpisode?['title'] as String? ?? _title) : (_chapters.isEmpty ? _title : _chapterName(chapterIdx))), chapterIndex: chapterIdx, totalChapters: totalChapters, itemId: _itemId),+ child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: (_isPodcastEpisode && _chapters.isEmpty) ? 0.0 : progress, staticDuration: (_isPodcastEpisode && _chapters.isEmpty) ? widget.player.totalDuration : _effectiveDuration, chapters: _chapters, showBookBar: false, showChapterBar: true, chapterName: (_isPodcastEpisode && _chapters.isEmpty) ? (widget.player.currentEpisodeTitle ?? widget.player.currentTitle ?? _title) : (_episodeId != null && !_isActive ? (_recentEpisode?['title'] as String? ?? _title) : (_chapters.isEmpty ? _title : _chapterName(chapterIdx))), chapterIndex: chapterIdx, totalChapters: totalChapters, itemId: _itemId, libraryId: _resolveLibraryId()),);final controlsAndButtons = MediaQuery(@@ -1246,6 +1246,7 @@ class _ExpandedCardState extends State<ExpandedCard> {item: _item,itemId: _itemId,episodeId: _episodeId,+ libraryId: _resolveLibraryId(),isPodcastEpisode: _isPodcastEpisode,title: _title,author: _author,diff --git a/lib/widgets/podcast_episode_feed.dart b/lib/widgets/podcast_episode_feed.dartindex 282d68ee..f12a7089 100644--- a/lib/widgets/podcast_episode_feed.dart+++ b/lib/widgets/podcast_episode_feed.dart@@ -485,6 +485,7 @@ class _PodcastEpisodeFeedState extends State<PodcastEpisodeFeed> {totalDuration: duration,chapters: chapters,episodeId: episodeId,+ libraryId: widget.libraryId,);return;}