Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix preview resume, episode download and editor seeking edge cases

Barnabas8cbd6c933953
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index a43fa7e5..8b5a1276 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -954,7 +954,7 @@
"trustAllCertificatesInfoTitle": "Self-signed Certificates",
"mp3IndexSeeking": "MP3 index seeking",
"mp3IndexSeekingInfoTitle": "MP3 Index Seeking",
- "mp3IndexSeekingInfoContent": "Only enable this if you have MP3 files that don't seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.",
+ "mp3IndexSeekingInfoContent": "Only enable this if you have MP3 files that don't seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.",
"mp3IndexSeekingOnSubtitle": "On - exact seeking for VBR MP3 files",
"mp3IndexSeekingOffSubtitle": "Off - normal seeking",
"trustAllCertificatesInfoContent": "Enable this if your Audiobookshelf server uses a self-signed certificate or a custom root CA. When enabled, Absorb will skip TLS certificate verification for all connections. Only enable this if you trust your network.",
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index 121aff85..01565d16 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -3721,7 +3721,7 @@ abstract class AppLocalizations {
/// No description provided for @mp3IndexSeekingInfoContent.
///
/// In en, this message translates to:
- /// **'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.'**
+ /// **'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.'**
String get mp3IndexSeekingInfoContent;
/// No description provided for @mp3IndexSeekingOnSubtitle.
diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart
index 358c8a61..27356bb8 100644
--- a/lib/l10n/app_localizations_de.dart
+++ b/lib/l10n/app_localizations_de.dart
@@ -2029,7 +2029,7 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dart
index ca877999..fd8216c8 100644
--- a/lib/l10n/app_localizations_el.dart
+++ b/lib/l10n/app_localizations_el.dart
@@ -2007,7 +2007,7 @@ class AppLocalizationsEl extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index 015931a3..6ad58038 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -2007,7 +2007,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart
index 16656879..10235443 100644
--- a/lib/l10n/app_localizations_es.dart
+++ b/lib/l10n/app_localizations_es.dart
@@ -2009,7 +2009,7 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart
index dd756f99..b837390e 100644
--- a/lib/l10n/app_localizations_fr.dart
+++ b/lib/l10n/app_localizations_fr.dart
@@ -2025,7 +2025,7 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart
index f0651af7..ea8e7071 100644
--- a/lib/l10n/app_localizations_it.dart
+++ b/lib/l10n/app_localizations_it.dart
@@ -2007,7 +2007,7 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart
index cc2b1920..d530f71e 100644
--- a/lib/l10n/app_localizations_ja.dart
+++ b/lib/l10n/app_localizations_ja.dart
@@ -2007,7 +2007,7 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dart
index 280bcc57..59ddd80e 100644
--- a/lib/l10n/app_localizations_no.dart
+++ b/lib/l10n/app_localizations_no.dart
@@ -2007,7 +2007,7 @@ class AppLocalizationsNo extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart
index af50d403..a6f6885c 100644
--- a/lib/l10n/app_localizations_pt.dart
+++ b/lib/l10n/app_localizations_pt.dart
@@ -2007,7 +2007,7 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dart
index 20638d60..0fea6987 100644
--- a/lib/l10n/app_localizations_ro.dart
+++ b/lib/l10n/app_localizations_ro.dart
@@ -2007,7 +2007,7 @@ class AppLocalizationsRo extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart
index b79c3812..4146976c 100644
--- a/lib/l10n/app_localizations_ru.dart
+++ b/lib/l10n/app_localizations_ru.dart
@@ -2011,7 +2011,7 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index ed30fd3a..292d6cc3 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -1958,7 +1958,7 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get mp3IndexSeekingInfoContent =>
- 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book starts.';
+ 'Only enable this if you have MP3 files that don\'t seek to the right position. Inaccurate seeking usually comes from variable bitrate (VBR) MP3s. Index seeking builds an exact time map as the file is read, so jumping near the end of a large MP3 can take a moment - especially when streaming, since the file has to be read up to that point. Takes effect the next time a book or podcast episode starts.';
@override
String get mp3IndexSeekingOnSubtitle =>
diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart
index a9e3306b..980310fd 100644
--- a/lib/providers/auth_provider.dart
+++ b/lib/providers/auth_provider.dart
@@ -945,6 +945,12 @@ class AuthProvider extends ChangeNotifier {
// previous account's values cached in widget state.
PlayerSettings.notifySettingsChanged();
+ // Synchronous PlayerSettings caches are loaded at startup, so refresh
+ // them from the new account's scope or playback keeps the old account's
+ // values until restart.
+ PlayerSettings.showExplicitBadge = await PlayerSettings.getShowExplicitBadge();
+ PlayerSettings.mp3IndexSeeking = await PlayerSettings.getMp3IndexSeeking();
+
// Reload EQ settings from the new account's scope. Without this the
// EqualizerService singleton keeps the previous account's in-memory
// state and would write it back into the new scope on any change.
diff --git a/lib/screens/chapter_editor_screen.dart b/lib/screens/chapter_editor_screen.dart
index 7e27cf58..a0da5661 100644
--- a/lib/screens/chapter_editor_screen.dart
+++ b/lib/screens/chapter_editor_screen.dart
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:just_audio/just_audio.dart';
+import '../services/offline_source.dart';
import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart';
import '../providers/auth_provider.dart';
@@ -513,7 +514,9 @@ class _ChapterEditBodyState extends State<ChapterEditBody>
});
if (done) _stopPreview();
});
- await player.setUrl(api.buildTrackUrl(contentUrl));
+ await player.setAudioSource(AudioSource.uri(
+ Uri.parse(api.buildTrackUrl(contentUrl)),
+ options: mp3ExtractorOptions()));
await player.seek(Duration(milliseconds: (seekSec * 1000).round()));
await player.play();
} catch (e) {
diff --git a/lib/screens/downloads_screen.dart b/lib/screens/downloads_screen.dart
index 7a00ca23..7fdbf3a0 100644
--- a/lib/screens/downloads_screen.dart
+++ b/lib/screens/downloads_screen.dart
@@ -177,13 +177,6 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final l = AppLocalizations.of(context)!;
- final allSelected = _selecting &&
- () {
- final visible = _visibleCompleted();
- return visible.isNotEmpty &&
- visible.every((d) => _selected.contains(d.itemId));
- }();
-
return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
body: SafeArea(
@@ -202,14 +195,24 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
),
),
if (_selecting) ...[
- IconButton(
- icon: Icon(
- allSelected
- ? Icons.deselect_rounded
- : Icons.select_all_rounded,
- color: cs.onSurfaceVariant),
- tooltip: allSelected ? l.deselectAll : l.selectAll,
- onPressed: _toggleSelectAll,
+ // Listens to DownloadService so a download completing
+ // mid-selection doesn't leave a stale all-selected look.
+ ListenableBuilder(
+ listenable: DownloadService(),
+ builder: (_, __) {
+ final visible = _visibleCompleted();
+ final allSelected = visible.isNotEmpty &&
+ visible.every((d) => _selected.contains(d.itemId));
+ return IconButton(
+ icon: Icon(
+ allSelected
+ ? Icons.deselect_rounded
+ : Icons.select_all_rounded,
+ color: cs.onSurfaceVariant),
+ tooltip: allSelected ? l.deselectAll : l.selectAll,
+ onPressed: _toggleSelectAll,
+ );
+ },
),
IconButton(
icon: Icon(Icons.close_rounded,
diff --git a/lib/services/bookmark_preview_player.dart b/lib/services/bookmark_preview_player.dart
index ab1cdfb8..1cc1a815 100644
--- a/lib/services/bookmark_preview_player.dart
+++ b/lib/services/bookmark_preview_player.dart
@@ -24,6 +24,7 @@ class BookmarkPreviewPlayer extends ChangeNotifier {
bool _playing = false;
bool _disposed = false;
bool? _mainWasPlaying;
+ String? _mainWasItemId;
Timer? _autoStop;
// Track-local position (ms) the current audition started at, so pausing then
@@ -124,6 +125,7 @@ class BookmarkPreviewPlayer extends ChangeNotifier {
}
_lastSeekMs = (local * 1000).round();
await player.seek(Duration(milliseconds: _lastSeekMs!));
+ if (_disposed) return;
// Start the auto-stop BEFORE awaiting play(): just_audio's play() future
// doesn't complete until playback ends, so a timer after it never armed -
// that's why the cap wasn't firing.
@@ -146,12 +148,22 @@ class BookmarkPreviewPlayer extends ChangeNotifier {
Future<void> _pauseMain() async {
final main = AudioPlayerService();
_mainWasPlaying ??= main.isPlaying;
+ _mainWasItemId ??= main.currentItemId;
if (main.isPlaying) await main.pause();
}
+ /// Resume the main player only if the book we paused is still the loaded
+ /// one and nothing else started playing meanwhile (the notification or
+ /// Android Auto can change both while an audition runs).
+ bool get _canResumeMain =>
+ _mainWasPlaying == true &&
+ !AudioPlayerService().isPlaying &&
+ AudioPlayerService().currentItemId == _mainWasItemId;
+
void _startAutoStop() {
_autoStop?.cancel();
_autoStop = Timer(clipLength, () {
+ if (_disposed) return;
debugPrint('[BookmarkPreview] auto-stop after ${clipLength.inSeconds}s');
if (stopOnClipEnd) {
unawaited(stop());
@@ -183,8 +195,9 @@ class BookmarkPreviewPlayer extends ChangeNotifier {
await _disposePlayer();
// Reset the snapshot even when it's false, or a sheet-lifetime player's
// second audition would pause the main book and never resume it.
- final shouldResume = _mainWasPlaying == true;
+ final shouldResume = _canResumeMain;
_mainWasPlaying = null;
+ _mainWasItemId = null;
if (shouldResume) await AudioPlayerService().play();
if (!_disposed) notifyListeners();
}
@@ -193,17 +206,19 @@ class BookmarkPreviewPlayer extends ChangeNotifier {
/// about to start real playback themselves.
Future<void> discard() async {
_mainWasPlaying = null;
+ _mainWasItemId = null;
await _disposePlayer();
if (!_disposed) notifyListeners();
}
@override
void dispose() {
+ final shouldResume = _canResumeMain;
_disposed = true;
_autoStop?.cancel();
_stateSub?.cancel();
_player?.dispose();
- if (_mainWasPlaying == true) AudioPlayerService().play();
+ if (shouldResume) AudioPlayerService().play();
super.dispose();
}
}
diff --git a/lib/services/clip_editor_controller.dart b/lib/services/clip_editor_controller.dart
index 6a412fdf..f506f139 100644
--- a/lib/services/clip_editor_controller.dart
+++ b/lib/services/clip_editor_controller.dart
@@ -90,8 +90,8 @@ class ClipEditorController extends ChangeNotifier {
if (track.local) {
await player.setAudioSource(localAudioSource(track.source));
} else {
- await player.setAudioSource(
- AudioSource.uri(Uri.parse(track.source), headers: api?.mediaHeaders));
+ await player.setAudioSource(AudioSource.uri(Uri.parse(track.source),
+ headers: api?.mediaHeaders, options: mp3ExtractorOptions()));
}
await player.seek(Duration(milliseconds: ((_position - _trackBase) * 1000).round()));
_posSub = player.positionStream.listen((d) {
diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dart
index 06945edf..f0d6a73f 100644
--- a/lib/widgets/book_detail_sheet.dart
+++ b/lib/widgets/book_detail_sheet.dart
@@ -1943,6 +1943,8 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
await _preview!.toggleAt(startAt);
} catch (e) {
debugPrint('[BookDetail] preview failed: $e');
+ // stop() resumes the main book we paused and resets for a retry.
+ await _preview?.stop();
if (mounted) {
showOverlayToast(context, l.bookmarkPreviewFailed, icon: Icons.error_outline_rounded);
}
diff --git a/lib/widgets/bookmark_detail_dialog.dart b/lib/widgets/bookmark_detail_dialog.dart
index 6068aef4..e0e032da 100644
--- a/lib/widgets/bookmark_detail_dialog.dart
+++ b/lib/widgets/bookmark_detail_dialog.dart
@@ -90,6 +90,8 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {
await _preview.toggleAt(_seconds);
} catch (e) {
debugPrint('[BookmarkPreview] toggle failed: $e');
+ // stop() resumes the main book we paused and resets for a retry.
+ await _preview.stop();
if (!mounted) return;
final l = AppLocalizations.of(context)!;
showOverlayToast(context, l.bookmarkPreviewFailed,
diff --git a/lib/widgets/episode_detail_sheet.dart b/lib/widgets/episode_detail_sheet.dart
index 6b3a5f0d..512fe316 100644
--- a/lib/widgets/episode_detail_sheet.dart
+++ b/lib/widgets/episode_detail_sheet.dart
@@ -163,7 +163,8 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
author: _showTitle,
coverUrl: api.getCoverUrl(_itemId),
episodeId: _episodeId,
- libraryId: context.read<LibraryProvider>().selectedLibraryId,
+ libraryId: widget.podcastItem['libraryId'] as String? ??
+ context.read<LibraryProvider>().selectedLibraryId,
);
if (error != null && mounted) {
showOverlayToast(context, error, icon: Icons.error_outline_rounded);
diff --git a/lib/widgets/episode_list_sheet.dart b/lib/widgets/episode_list_sheet.dart
index aeca3523..2b9e3ff5 100644
--- a/lib/widgets/episode_list_sheet.dart
+++ b/lib/widgets/episode_list_sheet.dart
@@ -196,6 +196,9 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
final media = fullItem['media'] as Map<String, dynamic>? ?? {};
final episodes = media['episodes'] as List<dynamic>? ?? [];
setState(() {
+ // Adopt the full item so a synthetic/lean map from the caller gets
+ // real metadata (title, description) once the fetch lands.
+ _podcastItem = Map<String, dynamic>.from(fullItem);
_episodes = _sortEpisodes(episodes);
_isLoading = false;
});
@@ -364,7 +367,8 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
author: _title,
coverUrl: coverUrl,
episodeId: episodeId,
- libraryId: context.read<LibraryProvider>().selectedLibraryId,
+ libraryId: _podcastItem['libraryId'] as String? ??
+ context.read<LibraryProvider>().selectedLibraryId,
);
if (error != null && mounted) {
diff --git a/lib/widgets/podcast_episode_feed.dart b/lib/widgets/podcast_episode_feed.dart
index 928c39c9..85814931 100644
--- a/lib/widgets/podcast_episode_feed.dart
+++ b/lib/widgets/podcast_episode_feed.dart
@@ -157,7 +157,9 @@ class _PodcastEpisodeFeedState extends State<PodcastEpisodeFeed> {
/// shape so the episode-list sheet fetches the show by the right id.
Map<String, dynamic> _podcastItemOf(Map<String, dynamic> ep) {
final podcast = ep['podcast'];
- if (podcast is Map<String, dynamic> && podcast['id'] != null) {
+ // No id gate: some payload shapes (minified podcast) carry metadata but
+ // no id - the episode's libraryItemId still identifies the show.
+ if (podcast is Map<String, dynamic>) {
if (podcast['media'] is Map<String, dynamic>) {
// Already library-item shaped (not the current payload - defensive).
return {
@@ -297,7 +299,7 @@ class _PodcastEpisodeFeedState extends State<PodcastEpisodeFeed> {
author: _showTitleOf(ep),
coverUrl: api.getCoverUrl(showId),
episodeId: episodeId,
- libraryId: widget.libraryId,
+ libraryId: ep['libraryId'] as String? ?? widget.libraryId,
);
if (error != null && mounted) {
showOverlayToast(context, error, icon: Icons.error_outline_rounded);