Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Queue improvements and playlist queue mode added

Barnabascbdf817987b6
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index 6a5668c3..65cbb711 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -317,6 +317,12 @@
"@queuePlaylistActiveLabel": { "placeholders": { "name": { "type": "String" } } },
"queueModePlaylistHint": "Start a playlist queue by opening a playlist on the home page.",
"exit": "Exit",
+ "upNext": "Up next: {label}",
+ "@upNext": { "placeholders": { "label": { "type": "String" } } },
+ "nothingUpNext": "Nothing up next",
+ "showUpNextLabel": "Show Up next on the absorbing page",
+ "openSeries": "Open series",
+ "openPlaylist": "Open playlist",
"playlistPlayAction": "Play playlist",
"playlistAllFinished": "All finished",
"queueModeBooks": "Books",
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index de00341e..b2796fb1 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -1792,6 +1792,36 @@ abstract class AppLocalizations {
/// **'Exit'**
String get exit;
+ /// No description provided for @upNext.
+ ///
+ /// In en, this message translates to:
+ /// **'Up next: {label}'**
+ String upNext(String label);
+
+ /// No description provided for @nothingUpNext.
+ ///
+ /// In en, this message translates to:
+ /// **'Nothing up next'**
+ String get nothingUpNext;
+
+ /// No description provided for @showUpNextLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Show Up next on the absorbing page'**
+ String get showUpNextLabel;
+
+ /// No description provided for @openSeries.
+ ///
+ /// In en, this message translates to:
+ /// **'Open series'**
+ String get openSeries;
+
+ /// No description provided for @openPlaylist.
+ ///
+ /// In en, this message translates to:
+ /// **'Open playlist'**
+ String get openPlaylist;
+
/// No description provided for @playlistPlayAction.
///
/// In en, this message translates to:
diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart
index de49a3f3..6bf5a4cf 100644
--- a/lib/l10n/app_localizations_de.dart
+++ b/lib/l10n/app_localizations_de.dart
@@ -935,6 +935,23 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get exit => 'Exit';
+ @override
+ String upNext(String label) {
+ return 'Up next: $label';
+ }
+
+ @override
+ String get nothingUpNext => 'Nothing up next';
+
+ @override
+ String get showUpNextLabel => 'Show Up next on the absorbing page';
+
+ @override
+ String get openSeries => 'Open series';
+
+ @override
+ String get openPlaylist => 'Open playlist';
+
@override
String get playlistPlayAction => 'Play playlist';
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index cd8fd64f..ada2e4d8 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -927,6 +927,23 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get exit => 'Exit';
+ @override
+ String upNext(String label) {
+ return 'Up next: $label';
+ }
+
+ @override
+ String get nothingUpNext => 'Nothing up next';
+
+ @override
+ String get showUpNextLabel => 'Show Up next on the absorbing page';
+
+ @override
+ String get openSeries => 'Open series';
+
+ @override
+ String get openPlaylist => 'Open playlist';
+
@override
String get playlistPlayAction => 'Play playlist';
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index f0cfc1c4..c7c6b693 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -903,6 +903,23 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get exit => 'Exit';
+ @override
+ String upNext(String label) {
+ return 'Up next: $label';
+ }
+
+ @override
+ String get nothingUpNext => 'Nothing up next';
+
+ @override
+ String get showUpNextLabel => 'Show Up next on the absorbing page';
+
+ @override
+ String get openSeries => 'Open series';
+
+ @override
+ String get openPlaylist => 'Open playlist';
+
@override
String get playlistPlayAction => 'Play playlist';
diff --git a/lib/providers/_lp_absorbing.dart b/lib/providers/_lp_absorbing.dart
index acd60913..097c8484 100644
--- a/lib/providers/_lp_absorbing.dart
+++ b/lib/providers/_lp_absorbing.dart
@@ -1081,4 +1081,206 @@ mixin _AbsorbingMixin on ChangeNotifier, _StateMixin, _CoreMixin {
}
debugPrint('[AutoAdvance] Playlist $playlistId exhausted after $finishedKey');
}
+
+ /// Returns the (seriesId, sequence) for [item]. Public wrapper around the
+ /// private `_StateMixin._extractSeries` so sheets in other files can use
+ /// it without reaching into private mixins.
+ (String?, double?) extractSeries(Map<String, dynamic> item) =>
+ _StateMixin._extractSeries(item);
+
+ // ── Public fetch helpers for sheets ─────────────────────────────────
+
+ Future<Map<String, dynamic>?> fetchLibraryItem(String itemId) async {
+ if (_api == null) return null;
+ final id = itemId.length > 36 ? itemId.substring(0, 36) : itemId;
+ return _api!.getLibraryItem(id);
+ }
+
+ Future<List<Map<String, dynamic>>> fetchBooksBySeries(
+ String libraryId, String seriesId) async {
+ if (_api == null) return const [];
+ final books = await _api!.getBooksBySeries(libraryId, seriesId, limit: 100);
+ return books.whereType<Map<String, dynamic>>().toList();
+ }
+
+ Future<Map<String, dynamic>?> fetchPlaylistById(String playlistId) =>
+ _getPlaylistById(playlistId);
+
+ // ── Up-next preview ─────────────────────────────────────────────────
+
+ String? _playlistItemTitle(Map<String, dynamic> item) {
+ final libraryItem = item['libraryItem'] as Map<String, dynamic>? ?? const {};
+ final media = libraryItem['media'] as Map<String, dynamic>? ?? const {};
+ final metadata = media['metadata'] as Map<String, dynamic>? ?? const {};
+ final epId = item['episodeId'] as String?;
+ if (epId != null) {
+ final ep = item['episode'] as Map<String, dynamic>? ??
+ (media['episodes'] as List<dynamic>? ?? const [])
+ .cast<Map<String, dynamic>>()
+ .where((e) => e['id'] == epId)
+ .firstOrNull;
+ return ep?['title'] as String? ?? metadata['title'] as String?;
+ }
+ return metadata['title'] as String?;
+ }
+
+ String? _entryTitle(Map<String, dynamic> entry) {
+ final media = entry['media'] as Map<String, dynamic>? ?? const {};
+ final metadata = media['metadata'] as Map<String, dynamic>? ?? const {};
+ final ep = entry['recentEpisode'] as Map<String, dynamic>?;
+ if (ep != null) return ep['title'] as String? ?? metadata['title'] as String?;
+ return metadata['title'] as String?;
+ }
+
+ /// Returns a short label describing what would play next given the current
+ /// queue mode and player state, or null when nothing is queued. Used by the
+ /// "Up next: ..." chip under the queue-mode pill on the absorbing page.
+ Future<String?> peekUpNext({required String? currentItemId}) async {
+ final self = this as LibraryProvider;
+ if (currentItemId == null) return null;
+
+ final isPodCurrent = currentItemId.length > 36;
+ final mode = isPodCurrent
+ ? await PlayerSettings.getPodcastQueueMode()
+ : await PlayerSettings.getBookQueueMode();
+ if (mode == 'off') return null;
+
+ if (mode == 'playlist') {
+ final pid = await PlayerSettings.getQueuePlaylistId();
+ if (pid == null) return null;
+ final pl = await _getPlaylistById(pid);
+ if (pl == null) return null;
+ final items = (pl['items'] as List<dynamic>?) ?? const [];
+ final playlistName = pl['name'] as String? ?? '';
+ // The current item must be in the active playlist - otherwise we're
+ // playing off-playlist and advance stops after this item.
+ int currentIdx = -1;
+ for (var i = 0; i < items.length; i++) {
+ final m = items[i];
+ if (m is Map<String, dynamic> && _playlistItemKey(m) == currentItemId) {
+ currentIdx = i;
+ break;
+ }
+ }
+ if (currentIdx < 0) return null;
+ for (var i = currentIdx + 1; i < items.length; i++) {
+ final m = items[i];
+ if (m is! Map<String, dynamic>) continue;
+ final key = _playlistItemKey(m);
+ if (key.isEmpty) continue;
+ if (self.isItemFinishedByKey(key)) continue;
+ final title = _playlistItemTitle(m);
+ return playlistName.isNotEmpty ? '$playlistName - $title' : title;
+ }
+ return null;
+ }
+
+ if (mode == 'manual') {
+ final idx = _absorbingBookIds.indexOf(currentItemId);
+ final start = idx >= 0 ? idx + 1 : 0;
+ for (var i = start; i < _absorbingBookIds.length; i++) {
+ final key = _absorbingBookIds[i];
+ if (self.isItemFinishedByKey(key)) continue;
+ final cached = _absorbingItemCache[key];
+ if (cached == null) continue;
+ return _entryTitle(cached);
+ }
+ return null;
+ }
+
+ // auto_next
+ if (isPodCurrent) {
+ return _peekNextPodcastEpisode(currentItemId);
+ }
+ return await _peekNextBookInSeries(currentItemId);
+ }
+
+ Future<String?> _peekNextBookInSeries(String currentBookId) async {
+ final self = this as LibraryProvider;
+ var data = _itemDataWithSeries(currentBookId);
+ var (seriesId, currentSeq) =
+ data != null ? _StateMixin._extractSeries(data) : (null, null);
+ if ((seriesId == null || currentSeq == null) && _api != null) {
+ final full = await _api!.getLibraryItem(currentBookId);
+ if (full != null) {
+ data = full;
+ (seriesId, currentSeq) = _StateMixin._extractSeries(full);
+ }
+ }
+ if (seriesId == null || currentSeq == null) return null;
+
+ final candidates = <double, Map<String, dynamic>>{};
+ void consider(String id, Map<String, dynamic> d) {
+ if (id == currentBookId) return;
+ if (self.isItemFinishedByKey(id)) return;
+ final (sid, seq) = _StateMixin._extractSeries(d);
+ if (sid != seriesId || seq == null || seq <= currentSeq!) return;
+ candidates[seq] = d;
+ }
+
+ for (final entry in _absorbingItemCache.entries) {
+ consider(entry.key, entry.value);
+ }
+ final dl = DownloadService();
+ for (final dlInfo in dl.downloadedItems) {
+ final id = dlInfo.itemId;
+ if (id.length > 36) continue;
+ if (candidates.values.any((d) => d['id'] == id)) continue;
+ final d = _itemDataWithSeries(id);
+ if (d != null) consider(id, d);
+ }
+
+ // Server fallback when next book isn't loaded locally. Mirrors what
+ // _addNextSeriesBookToAbsorbing does so the peek matches the eventual
+ // advance behaviour.
+ if (candidates.isEmpty && _api != null && _selectedLibraryId != null) {
+ try {
+ final books = await _api!.getBooksBySeries(
+ _selectedLibraryId!,
+ seriesId,
+ limit: 100,
+ );
+ for (final book in books) {
+ if (book is! Map<String, dynamic>) continue;
+ final id = book['id'] as String?;
+ if (id == null) continue;
+ consider(id, book);
+ }
+ } catch (e) {
+ debugPrint('[UpNext] series fetch failed: $e');
+ }
+ }
+
+ if (candidates.isEmpty) return null;
+ final nextSeq = candidates.keys.toList()..sort();
+ final next = candidates[nextSeq.first]!;
+ return _entryTitle(next);
+ }
+
+ String? _peekNextPodcastEpisode(String currentCompoundKey) {
+ if (currentCompoundKey.length < 37) return null;
+ final showId = currentCompoundKey.substring(0, 36);
+ final currentEpId = currentCompoundKey.substring(37);
+ final showCached = _absorbingItemCache.values.cast<Map<String, dynamic>>().where((e) {
+ final mt = e['mediaType'] as String?;
+ return mt == 'podcast' && (e['id'] as String?) == showId;
+ }).firstOrNull;
+ if (showCached == null) return null;
+ final media = showCached['media'] as Map<String, dynamic>? ?? const {};
+ final eps = (media['episodes'] as List<dynamic>? ?? const [])
+ .whereType<Map<String, dynamic>>()
+ .toList();
+ if (eps.isEmpty) return null;
+ final self = this as LibraryProvider;
+ final currentIdx = eps.indexWhere((e) => e['id'] == currentEpId);
+ final start = currentIdx >= 0 ? currentIdx + 1 : 0;
+ for (var i = start; i < eps.length; i++) {
+ final ep = eps[i];
+ final epId = ep['id'] as String?;
+ if (epId == null) continue;
+ if (self.isItemFinishedByKey('$showId-$epId')) continue;
+ return ep['title'] as String?;
+ }
+ return null;
+ }
}
diff --git a/lib/providers/_lp_state.dart b/lib/providers/_lp_state.dart
index 8381c39e..87f1c853 100644
--- a/lib/providers/_lp_state.dart
+++ b/lib/providers/_lp_state.dart
@@ -320,16 +320,11 @@ mixin _StateMixin on ChangeNotifier {
if (_api != null && !isOffline) {
final ts = _itemUpdatedAt[apiItemId];
- final url = _api!.getCoverUrl(apiItemId, width: width, updatedAt: ts);
- debugPrint('[Cover] network $apiItemId ts=$ts -> $url');
- return url;
+ return _api!.getCoverUrl(apiItemId, width: width, updatedAt: ts);
}
final dl = DownloadService().getInfo(itemId);
if (dl.localCoverPath != null) {
- final f = File(dl.localCoverPath!);
- final mtime = f.existsSync() ? f.lastModifiedSync().millisecondsSinceEpoch : -1;
- debugPrint('[Cover] local $itemId path=${dl.localCoverPath} mtime=$mtime');
return dl.localCoverPath;
}
diff --git a/lib/providers/library_provider.dart b/lib/providers/library_provider.dart
index 2f543871..fb476242 100644
--- a/lib/providers/library_provider.dart
+++ b/lib/providers/library_provider.dart
@@ -33,10 +33,6 @@ class LibraryProvider extends ChangeNotifier
// where updateAuth may not run until much later).
AudioPlayerService.setOnBookFinishedCallback(markFinishedLocally);
AudioPlayerService.setOnPlayStartedCallback((key) {
- // If a non-playlist item is being played while playlist mode is active,
- // exit playlist mode. Lets users escape the queue by just tapping any
- // other book/episode (matches "Auto-switch mode to off" UX choice).
- _checkPlaylistModeOnPlay(key);
Future.delayed(const Duration(seconds: 30), () {
final stillPlaying = AudioPlayerService().isPlaying;
if (!stillPlaying) return;
@@ -385,26 +381,4 @@ class LibraryProvider extends ChangeNotifier
return getProgressData(key)?['isFinished'] == true;
}
- /// If queue mode is 'playlist' and [progressKey] is not in the active
- /// playlist, clear playlist mode (modes back to 'off'). Fire-and-forget.
- Future<void> _checkPlaylistModeOnPlay(String progressKey) async {
- try {
- final mode = await PlayerSettings.getBookQueueMode();
- if (mode != 'playlist') return;
- final libraryItemId =
- progressKey.length > 36 ? progressKey.substring(0, 36) : progressKey;
- final episodeId =
- progressKey.length > 36 ? progressKey.substring(37) : null;
- final inPlaylist = await isInActiveQueuePlaylist(
- libraryItemId,
- episodeId: episodeId,
- );
- if (!inPlaylist) {
- debugPrint('[Playlist] Off-queue play; clearing playlist queue mode');
- await PlayerSettings.clearQueueModePlaylist();
- }
- } catch (e) {
- debugPrint('[Playlist] _checkPlaylistModeOnPlay error: $e');
- }
- }
}
diff --git a/lib/screens/absorbing_screen.dart b/lib/screens/absorbing_screen.dart
index c81129c9..8888c264 100644
--- a/lib/screens/absorbing_screen.dart
+++ b/lib/screens/absorbing_screen.dart
@@ -2,16 +2,20 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
+import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
import '../services/audio_player_service.dart';
import '../services/chromecast_service.dart';
import '../services/download_service.dart';
import '../services/scoped_prefs.dart';
import '../widgets/absorb_page_header.dart';
-import '../main.dart' show oledNotifier;
+import '../main.dart' show oledNotifier, rootNavigatorKey;
import '../widgets/absorbing_card.dart';
import '../widgets/feature_hint.dart';
import '../widgets/offline_status_icon.dart';
+import '../widgets/overlay_toast.dart';
+import '../widgets/series_books_sheet.dart';
+import '../widgets/playlist_detail_sheet.dart';
import '../l10n/app_localizations.dart';
import '../services/wording.dart';
@@ -111,14 +115,35 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
mode = lib.isPodcastLibrary ? pm : bm;
}
final qpId = await PlayerSettings.getQueuePlaylistId();
+ final showUpNext = await PlayerSettings.getShowUpNextLabel();
if (mounted) {
setState(() {
_queueMode = mode;
_queuePlaylistId = qpId;
+ _showUpNextLabel = showUpNext;
});
+ _refreshUpNext();
}
}
+ bool _showUpNextLabel = true;
+ String? _upNextLabel;
+ String? _upNextComputedFor;
+ Future<void> _refreshUpNext() async {
+ final lib = context.read<LibraryProvider>();
+ final currentId = _player.currentEpisodeId != null
+ ? '${_player.currentItemId}-${_player.currentEpisodeId}'
+ : _player.currentItemId;
+ final firstKey = lib.absorbingBookIds.isNotEmpty ? lib.absorbingBookIds.first : '';
+ final stamp = '$_queueMode|$_queuePlaylistId|$currentId|$firstKey';
+ if (stamp == _upNextComputedFor) return;
+ _upNextComputedFor = stamp;
+ final label = await lib.peekUpNext(currentItemId: currentId);
+ if (!mounted) return;
+ if (stamp != _upNextComputedFor) return;
+ if (label != _upNextLabel) setState(() => _upNextLabel = label);
+ }
+
@override
void dispose() {
_player.removeListener(_rebuild);
@@ -156,6 +181,7 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
// Detect item or episode change (same show, different episode counts as a change)
final itemChanged = _player.currentItemId != _lastPlayingId;
final episodeChanged = _player.currentEpisodeId != _lastPlayingEpisodeId;
+ if (itemChanged || episodeChanged) _refreshUpNext();
if (itemChanged || episodeChanged) {
final wasPlayingId = _lastPlayingId;
final wasEpisodeId = _lastPlayingEpisodeId;
@@ -500,6 +526,7 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
Widget build(BuildContext context) {
_loadMergeLibraries(); // refresh in case setting changed
_loadQueueMode(); // refresh for current library type
+ _refreshUpNext(); // stamp short-circuits when nothing changed
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final l = AppLocalizations.of(context)!;
@@ -723,6 +750,29 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
// Phone landscape uses the compact single-row header; everything
// else (portrait, tablets in any orientation) keeps the full header.
if (isPhoneLandscape) landscapeHeader else portraitHeader,
+ if (_showUpNextLabel && _queueMode != 'off' && books.isNotEmpty)
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 2),
+ child: Align(
+ alignment: Alignment.centerRight,
+ child: Builder(builder: (context) {
+ final isDark = Theme.of(context).brightness == Brightness.dark;
+ final greenColor = isDark ? Colors.greenAccent[400] : Colors.green.shade700;
+ final redColor = isDark ? Colors.redAccent[200] : Colors.red.shade700;
+ final hasNext = _upNextLabel != null;
+ return Text(
+ hasNext ? l.upNext(_upNextLabel!) : l.nothingUpNext,
+ style: TextStyle(
+ fontSize: 10,
+ fontWeight: FontWeight.w600,
+ color: hasNext ? greenColor : redColor,
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ );
+ }),
+ ),
+ ),
// ── Page Dots (compact header inlines them in phone landscape) ──
if (!isPhoneLandscape && pageDots != null)
Padding(
@@ -856,15 +906,26 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
queueMode: _queueMode,
isMerged: _mergeLibraries,
isPodcast: lib.isPodcastLibrary,
+ currentItemId: _player.currentEpisodeId != null
+ ? '${_player.currentItemId}-${_player.currentEpisodeId}'
+ : _player.currentItemId,
onQueueModeChanged: (mode) async {
- final wasPlaylist = _queueMode == 'playlist';
- if (_mergeLibraries || wasPlaylist) {
- // Merged view OR leaving playlist mode: keep both types in sync
+ if (mode == 'playlist') {
+ final pid = await PlayerSettings.getQueuePlaylistId();
+ if (pid == null) {
+ if (context.mounted) {
+ final hint = AppLocalizations.of(context)!.queueModePlaylistHint;
+ showOverlayToast(context, hint,
+ icon: Icons.playlist_play_rounded);
+ }
+ return;
+ }
+ await PlayerSettings.setQueueModePlaylist(pid);
+ return;
+ }
+ if (_mergeLibraries || _queueMode == 'playlist') {
await PlayerSettings.setBookQueueMode(mode);
await PlayerSettings.setPodcastQueueMode(mode);
- if (wasPlaylist) {
- await PlayerSettings.setQueuePlaylistId(null);
- }
} else {
final isPod = lib.isPodcastLibrary;
if (isPod) {
@@ -948,6 +1009,7 @@ class _ReorderAbsorbingSheet extends StatefulWidget {
final bool isMerged;
final bool isPodcast;
final ValueChanged<String> onQueueModeChanged;
+ final String? currentItemId;
const _ReorderAbsorbingSheet({
required this.keys,
@@ -958,6 +1020,7 @@ class _ReorderAbsorbingSheet extends StatefulWidget {
required this.isMerged,
required this.isPodcast,
required this.onQueueModeChanged,
+ required this.currentItemId,
});
@override
@@ -978,6 +1041,86 @@ class _ReorderAbsorbingSheetState extends State<_ReorderAbsorbingSheet> {
};
_queueMode = widget.queueMode;
PlayerSettings.settingsChanged.addListener(_refreshMode);
+ PlayerSettings.getShowUpNextLabel().then((v) {
+ if (mounted) setState(() => _showUpNext = v);
+ });
+ _loadModeContent();
+ }
+
+ bool _showUpNext = true;
+
+ // Stage 3: mode-aware rendering. For auto_next we show the active series'
+ // books; for playlist we show the active playlist's items. Cached here so
+ // the list paints without a flash while the API call completes.
+ List<Map<String, dynamic>>? _seriesBooks;
+ String? _seriesId;
+ String? _seriesName;
+ List<Map<String, dynamic>>? _playlistItems;
+ String? _playlistId;
+ String? _playlistName;
+
+ Future<void> _loadModeContent() async {
+ if (_queueMode == 'auto_next' && !widget.isPodcast) {
+ await _loadSeriesBooks();
+ } else if (_queueMode == 'playlist') {
+ await _loadPlaylistContent();
+ }
+ }
+
+ Future<void> _loadSeriesBooks() async {
+ final currentId = widget.currentItemId;
+ if (currentId == null) return;
+ final cache = widget.lib.absorbingItemCache;
+ Map<String, dynamic>? data = cache[currentId];
+ final auth = widget.lib;
+ // Fall back to the server if we don't have full series metadata cached.
+ if (data == null || widget.lib.extractSeries(data).$1 == null) {
+ final fetched = await auth.fetchLibraryItem(currentId);
+ if (fetched != null) data = fetched;
+ }
+ if (data == null) return;
+ final (sid, _) = widget.lib.extractSeries(data);
+ if (sid == null) return;
+ final libraryId = data['libraryId'] as String? ?? widget.lib.selectedLibraryId;
+ if (libraryId == null) return;
+ final books = await auth.fetchBooksBySeries(libraryId, sid);
+ if (!mounted) return;
+ // Pull the series name from the current book's metadata.
+ final media = data['media'] as Map<String, dynamic>? ?? const {};
+ final metadata = media['metadata'] as Map<String, dynamic>? ?? const {};
+ final seriesRaw = metadata['series'];
+ String? seriesName;
+ if (seriesRaw is List) {
+ for (final s in seriesRaw) {
+ if (s is Map && s['id'] == sid) {
+ seriesName = s['name'] as String?;
+ break;
+ }
+ }
+ } else if (seriesRaw is Map) {
+ seriesName = seriesRaw['name'] as String?;
+ }
+ setState(() {
+ _seriesBooks = books;
+ _seriesId = sid;
+ _seriesName = seriesName;
+ });
+ }
+
+ Future<void> _loadPlaylistContent() async {
+ final pid = await PlayerSettings.getQueuePlaylistId();
+ if (pid == null) return;
+ final pl = await widget.lib.fetchPlaylistById(pid);
+ if (!mounted) return;
+ if (pl == null) return;
+ final items = ((pl['items'] as List<dynamic>?) ?? const [])
+ .whereType<Map<String, dynamic>>()
+ .toList();
+ setState(() {
+ _playlistItems = items;
+ _playlistId = pid;
+ _playlistName = pl['name'] as String?;
+ });
}
@override
@@ -1000,7 +1143,10 @@ class _ReorderAbsorbingSheetState extends State<_ReorderAbsorbingSheet> {
} else {
mode = widget.isPodcast ? pm : bm;
}
- if (mounted && mode != _queueMode) setState(() => _queueMode = mode);
+ if (mounted && mode != _queueMode) {
+ setState(() => _queueMode = mode);
+ _loadModeContent();
+ }
}
@override
@@ -1040,62 +1186,18 @@ class _ReorderAbsorbingSheetState extends State<_ReorderAbsorbingSheet> {
),
]),
),
- if (_queueMode == 'playlist')
- Padding(
- padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
- child: Container(
- padding: const EdgeInsets.fromLTRB(10, 4, 4, 4),
- decoration: BoxDecoration(
- color: cs.primaryContainer.withValues(alpha: 0.45),
- borderRadius: BorderRadius.circular(12),
- border: Border.all(color: cs.primary.withValues(alpha: 0.25), width: 0.5),
- ),
- child: Row(children: [
- Icon(Icons.playlist_play_rounded, size: 16, color: cs.primary),
- const SizedBox(width: 8),
- Expanded(child: FutureBuilder<String?>(
- future: PlayerSettings.getQueuePlaylistId(),
- builder: (context, snap) {
- String name = l.queuePlaylistNone;
- final id = snap.data;
- if (id != null) {
- final match = widget.lib.playlists.cast<Map<String, dynamic>>().where(
- (p) => p['id'] == id,
- ).firstOrNull;
- final n = match?['name'] as String?;
- if (n != null && n.isNotEmpty) name = n;
- }
- return Text(
- name,
- style: tt.bodySmall?.copyWith(color: cs.onPrimaryContainer, fontWeight: FontWeight.w600),
- maxLines: 1, overflow: TextOverflow.ellipsis,
- );
- },
- )),
- IconButton(
- icon: const Icon(Icons.close_rounded, size: 16),
- color: cs.onPrimaryContainer.withValues(alpha: 0.7),
- padding: EdgeInsets.zero,
- constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
- visualDensity: VisualDensity.compact,
- tooltip: l.exit,
- onPressed: () => PlayerSettings.clearQueueModePlaylist(),
- ),
- ]),
- ),
- ),
// Queue mode toggle
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
child: SegmentedButton<String>(
- emptySelectionAllowed: true,
segments: [
ButtonSegment(value: 'off', icon: const Icon(Icons.stop_rounded, size: 16), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeOff, maxLines: 1))),
ButtonSegment(value: 'manual', icon: const Icon(Icons.queue_music_rounded, size: 16), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeManual, maxLines: 1))),
ButtonSegment(value: 'auto_next', icon: const Icon(Icons.skip_next_rounded, size: 16),
label: FittedBox(fit: BoxFit.scaleDown, child: Text(widget.isMerged ? l.queueModeAuto : widget.isPodcast ? l.queueModeShowLabel : l.queueModeSeriesLabel, maxLines: 1))),
+ ButtonSegment(value: 'playlist', icon: const Icon(Icons.playlist_play_rounded, size: 16), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModePlaylist, maxLines: 1))),
],
- selected: _queueMode == 'playlist' ? const <String>{} : {_queueMode},
+ selected: {_queueMode},
onSelectionChanged: (v) {
if (v.isNotEmpty) widget.onQueueModeChanged(v.first);
},
@@ -1105,14 +1207,315 @@ class _ReorderAbsorbingSheetState extends State<_ReorderAbsorbingSheet> {
),
),
),
+ if (_queueMode != 'off')
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 0, 16, 4),
+ child: Row(children: [
+ Expanded(child: Text(l.showUpNextLabel,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant))),
+ Switch(
+ value: _showUpNext,
+ onChanged: (v) {
+ setState(() => _showUpNext = v);
+ PlayerSettings.setShowUpNextLabel(v);
+ },
+ materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ ),
+ ]),
+ ),
FeatureHint(
prefKey: 'hint_playlist_queue_mode',
message: l.queueModePlaylistHint,
icon: Icons.playlist_play_rounded,
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
),
+ if (_queueMode == 'auto_next' && !widget.isPodcast && _seriesId != null)
+ _modeHeaderButton(
+ cs, tt,
+ label: l.openSeries,
+ subtitle: _seriesName,
+ icon: Icons.collections_bookmark_rounded,
+ onTap: () {
+ final auth = context.read<AuthProvider>();
+ final outer = rootNavigatorKey.currentContext ?? context;
+ Navigator.pop(context);
+ showSeriesBooksSheet(
+ outer,
+ seriesName: _seriesName ?? '',
+ seriesId: _seriesId,
+ books: const [],
+ serverUrl: auth.serverUrl,
+ token: auth.token,
+ libraryId: widget.lib.selectedLibraryId,
+ );
+ },
+ ),
+ if (_queueMode == 'playlist' && _playlistId != null)
+ _modeHeaderButton(
+ cs, tt,
+ label: l.openPlaylist,
+ subtitle: _playlistName,
+ icon: Icons.playlist_play_rounded,
+ onTap: () {
+ final outer = rootNavigatorKey.currentContext ?? context;
+ Navigator.pop(context);
+ PlaylistDetailSheet.show(outer, _playlistId!);
+ },
+ ),
Expanded(
- child: ReorderableListView.builder(
+ child: _buildQueueList(cs, tt, l, bottomInset),
+ ),
+ ]),
+ );
+ }
+
+ Widget _modeHeaderButton(
+ ColorScheme cs,
+ TextTheme tt, {
+ required String label,
+ String? subtitle,
+ required IconData icon,
+ required VoidCallback onTap,
+ }) {
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
+ child: InkWell(
+ onTap: onTap,
+ borderRadius: BorderRadius.circular(12),
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
+ decoration: BoxDecoration(
+ color: cs.surfaceContainerHighest.withValues(alpha: 0.5),
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Row(children: [
+ Icon(icon, size: 18, color: cs.primary),
+ const SizedBox(width: 10),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(label,
+ style: tt.bodyMedium?.copyWith(fontWeight: FontWeight.w600)),
+ if (subtitle != null && subtitle.isNotEmpty)
+ Text(subtitle,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ ],
+ ),
+ ),
+ Icon(Icons.chevron_right_rounded, size: 18, color: cs.onSurfaceVariant),
+ ]),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildQueueList(ColorScheme cs, TextTheme tt, AppLocalizations l, double bottomInset) {
+ if (_queueMode == 'auto_next' && !widget.isPodcast) {
+ return _buildSeriesList(cs, tt, l, bottomInset);
+ }
+ if (_queueMode == 'playlist') {
+ return _buildPlaylistList(cs, tt, l, bottomInset);
+ }
+ return _buildManualList(cs, tt, l, bottomInset);
+ }
+
+ Widget _buildSeriesList(ColorScheme cs, TextTheme tt, AppLocalizations l, double bottomInset) {
+ final books = _seriesBooks;
+ if (books == null) {
+ return const Center(child: CircularProgressIndicator(strokeWidth: 2));
+ }
+ if (books.isEmpty) {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.all(24),
+ child: Text(l.absorbingNothingAbsorbingYet,
+ style: tt.bodyMedium?.copyWith(color: cs.onSurfaceVariant)),
+ ),
+ );
+ }
+ // Sort by series sequence (numeric leading).
+ books.sort((a, b) {
+ double seqOf(Map<String, dynamic> book) {
+ final (_, seq) = widget.lib.extractSeries(book);
+ return seq ?? double.maxFinite;
+ }
+ return seqOf(a).compareTo(seqOf(b));
+ });
+ return ListView.builder(
+ padding: EdgeInsets.only(bottom: bottomInset + 16),
+ itemCount: books.length,
+ itemBuilder: (context, i) {
+ final book = books[i];
+ final id = book['id'] as String? ?? '';
+ return _readOnlyQueueItem(cs, tt, l, key: id, book: book, index: i);
+ },
+ );
+ }
+
+ Widget _buildPlaylistList(ColorScheme cs, TextTheme tt, AppLocalizations l, double bottomInset) {
+ final items = _playlistItems;
+ if (items == null) {
+ return const Center(child: CircularProgressIndicator(strokeWidth: 2));
+ }
+ if (items.isEmpty) {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.all(24),
+ child: Text(l.playlistAllFinished,
+ style: tt.bodyMedium?.copyWith(color: cs.onSurfaceVariant)),
+ ),
+ );
+ }
+ return ListView.builder(
+ padding: EdgeInsets.only(bottom: bottomInset + 16),
+ itemCount: items.length,
+ itemBuilder: (context, i) {
+ final item = items[i];
+ final libraryItemId = item['libraryItemId'] as String? ?? '';
+ final episodeId = item['episodeId'] as String?;
+ final key = episodeId != null ? '$libraryItemId-$episodeId' : libraryItemId;
+ final book = item['libraryItem'] as Map<String, dynamic>? ?? const {};
+ return _readOnlyQueueItem(
+ cs, tt, l,
+ key: key,
+ book: book,
+ index: i,
+ episodeOverride: item['episode'] as Map<String, dynamic>?,
+ );
+ },
+ );
+ }
+
+ Widget _readOnlyQueueItem(
+ ColorScheme cs,
+ TextTheme tt,
+ AppLocalizations l, {
+ required String key,
+ required Map<String, dynamic> book,
+ required int index,
+ Map<String, dynamic>? episodeOverride,
+ }) {
+ final media = book['media'] as Map<String, dynamic>? ?? const {};
+ final metadata = media['metadata'] as Map<String, dynamic>? ?? const {};
+ final title = metadata['title'] as String? ?? l.unknown;
+ final author = metadata['authorName'] as String? ?? '';
+ final epTitle = episodeOverride?['title'] as String?;
+ final isFinished = widget.lib.isItemFinishedByKey(key);
+ final isPlaying = widget.currentItemId == key;
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
+ child: InkWell(
+ borderRadius: BorderRadius.circular(12),
+ onTap: () {
+ // Tapping a series book or playlist item plays it. For playlist
+ // items the user expects this to be the same as opening the item
+ // from the playlist sheet; closing the manage queue sheet first.
+ Navigator.pop(context);
+ final api = context.read<AuthProvider>().apiService;
+ if (api == null) return;
+ if (key.length > 36) {
+ // podcast compound key
+ final showId = key.substring(0, 36);
+ final epId = key.substring(37);
+ AudioPlayerService().playItem(
+ api: api,
+ itemId: showId,
+ title: epTitle ?? title,
+ author: title,
+ coverUrl: widget.lib.getCoverUrl(showId),
+ totalDuration: (episodeOverride?['duration'] as num?)?.toDouble() ?? 0,
+ chapters: const [],
+ episodeId: epId,
+ episodeTitle: epTitle,
+ );
+ } else {
+ AudioPlayerService().playItem(
+ api: api,
+ itemId: key,
+ title: title,
+ author: author,
+ coverUrl: widget.lib.getCoverUrl(key),
+ totalDuration: (media['duration'] as num?)?.toDouble() ?? 0,
+ chapters: media['chapters'] as List<dynamic>? ?? const [],
+ );
+ }
+ },
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
+ decoration: BoxDecoration(
+ color: isPlaying
+ ? cs.primaryContainer.withValues(alpha: 0.25)
+ : (isFinished ? cs.onSurface.withValues(alpha: 0.03) : Colors.transparent),
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Row(children: [
+ SizedBox(
+ width: 24,
+ child: Text('${index + 1}',
+ style: tt.labelMedium?.copyWith(
+ color: isFinished ? cs.onSurface.withValues(alpha: 0.3) : cs.primary,
+ fontWeight: FontWeight.w700,
+ )),
+ ),
+ if (isFinished)
+ Icon(Icons.check_circle_rounded,
+ size: 16, color: Colors.green.withValues(alpha: 0.5))
+ else
+ () {
+ final progress = widget.lib.getProgress(key);
+ return progress > 0
+ ? SizedBox(
+ width: 16,
+ height: 16,
+ child: CircularProgressIndicator(
+ value: progress,
+ strokeWidth: 2.5,
+ backgroundColor: cs.surfaceContainerHighest,
+ color: cs.primary,
+ ),
+ )
+ : Icon(Icons.circle_outlined,
+ size: 16, color: cs.onSurface.withValues(alpha: 0.2));
+ }(),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(epTitle ?? title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: tt.bodyMedium?.copyWith(
+ color: isFinished
+ ? cs.onSurface.withValues(alpha: 0.4)
+ : null,
+ )),
+ if (epTitle != null)
+ Text(title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant))
+ else if (author.isNotEmpty)
+ Text(author,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ ],
+ ),
+ ),
+ ]),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildManualList(ColorScheme cs, TextTheme tt, AppLocalizations l, double bottomInset) {
+ return ReorderableListView.builder(
buildDefaultDragHandles: false,
onReorderStart: (_) => HapticFeedback.mediumImpact(),
padding: EdgeInsets.only(bottom: bottomInset + 16),
@@ -1226,10 +1629,7 @@ class _ReorderAbsorbingSheetState extends State<_ReorderAbsorbingSheet> {
),
);
},
- ),
- ),
- ]),
- );
+ );
}
}
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index cc4142c7..de0e4284 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -168,23 +168,20 @@ class _SettingsScreenState extends State<SettingsScreen> {
}
}
- Future<String?> _pickQueuePlaylist() async {
- if (!mounted) return null;
- return await QueuePlaylistPickerSheet.show(context);
- }
-
Future<void> _enterPlaylistMode() async {
- String? id = _queuePlaylistId;
+ final id = _queuePlaylistId;
if (id == null) {
- id = await _pickQueuePlaylist();
- if (id == null || !mounted) return;
+ if (!mounted) return;
+ final l = AppLocalizations.of(context)!;
+ showOverlayToast(context, l.queueModePlaylistHint,
+ icon: Icons.playlist_play_rounded);
+ return;
}
await PlayerSettings.setQueueModePlaylist(id);
if (!mounted) return;
setState(() {
_bookQueueMode = 'playlist';
_podcastQueueMode = 'playlist';
- _queuePlaylistId = id;
});
}
@@ -195,15 +192,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
await PlayerSettings.setBookQueueMode(mode);
if (wasPlaylist) {
await PlayerSettings.setPodcastQueueMode(mode);
- await PlayerSettings.setQueuePlaylistId(null);
}
if (!mounted) return;
setState(() {
_bookQueueMode = mode;
- if (wasPlaylist) {
- _podcastQueueMode = mode;
- _queuePlaylistId = null;
- }
+ if (wasPlaylist) _podcastQueueMode = mode;
});
PlayerSettings.notifySettingsChanged();
}
@@ -215,15 +208,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
await PlayerSettings.setPodcastQueueMode(mode);
if (wasPlaylist) {
await PlayerSettings.setBookQueueMode(mode);
- await PlayerSettings.setQueuePlaylistId(null);
}
if (!mounted) return;
setState(() {
_podcastQueueMode = mode;
- if (wasPlaylist) {
- _bookQueueMode = mode;
- _queuePlaylistId = null;
- }
+ if (wasPlaylist) _bookQueueMode = mode;
});
PlayerSettings.notifySettingsChanged();
}
@@ -272,18 +261,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
Future<void> _setMergedQueueMode(String mode) async {
if (mode == 'playlist') return _enterPlaylistMode();
- final wasPlaylist =
- _bookQueueMode == 'playlist' || _podcastQueueMode == 'playlist';
await PlayerSettings.setBookQueueMode(mode);
await PlayerSettings.setPodcastQueueMode(mode);
- if (wasPlaylist) {
- await PlayerSettings.setQueuePlaylistId(null);
- }
if (!mounted) return;
setState(() {
_bookQueueMode = mode;
_podcastQueueMode = mode;
- if (wasPlaylist) _queuePlaylistId = null;
});
PlayerSettings.notifySettingsChanged();
}
@@ -1010,13 +993,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
const SizedBox(height: 8),
SizedBox(width: double.infinity, child: SegmentedButton<String>(
showSelectedIcon: false,
- emptySelectionAllowed: true,
segments: [
ButtonSegment(value: 'off', icon: const Icon(Icons.stop_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeOff))),
ButtonSegment(value: 'manual', icon: const Icon(Icons.queue_music_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeManual))),
ButtonSegment(value: 'auto_next', icon: const Icon(Icons.skip_next_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeAuto))),
+ ButtonSegment(value: 'playlist', icon: const Icon(Icons.playlist_play_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModePlaylist))),
],
- selected: _mergedQueueMode == 'playlist' ? const <String>{} : {_mergedQueueMode},
+ selected: {_mergedQueueMode},
onSelectionChanged: _loaded
? (s) { if (s.isNotEmpty) _setMergedQueueMode(s.first); }
: null,
@@ -1028,13 +1011,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
const SizedBox(height: 4),
SizedBox(width: double.infinity, child: SegmentedButton<String>(
showSelectedIcon: false,
- emptySelectionAllowed: true,
segments: [
ButtonSegment(value: 'off', icon: const Icon(Icons.stop_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeOff))),
ButtonSegment(value: 'manual', icon: const Icon(Icons.queue_music_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeManual))),
ButtonSegment(value: 'auto_next', icon: const Icon(Icons.skip_next_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeSeriesLabel))),
+ ButtonSegment(value: 'playlist', icon: const Icon(Icons.playlist_play_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModePlaylist))),
],
- selected: _bookQueueMode == 'playlist' ? const <String>{} : {_bookQueueMode},
+ selected: {_bookQueueMode},
onSelectionChanged: _loaded
? (s) { if (s.isNotEmpty) _setBookQueueMode(s.first); }
: null,
@@ -1046,13 +1029,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
const SizedBox(height: 4),
SizedBox(width: double.infinity, child: SegmentedButton<String>(
showSelectedIcon: false,
- emptySelectionAllowed: true,
segments: [
ButtonSegment(value: 'off', icon: const Icon(Icons.stop_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeOff))),
ButtonSegment(value: 'manual', icon: const Icon(Icons.queue_music_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeManual))),
ButtonSegment(value: 'auto_next', icon: const Icon(Icons.skip_next_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeShowLabel))),
+ ButtonSegment(value: 'playlist', icon: const Icon(Icons.playlist_play_rounded, size: 18), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModePlaylist))),
],
- selected: _podcastQueueMode == 'playlist' ? const <String>{} : {_podcastQueueMode},
+ selected: {_podcastQueueMode},
onSelectionChanged: _loaded
? (s) { if (s.isNotEmpty) _setPodcastQueueMode(s.first); }
: null,
@@ -1060,10 +1043,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
)),
],
],
- if (_mergedQueueMode == 'playlist') ...[
- const SizedBox(height: 8),
- _buildActivePlaylistRow(cs, tt, lib, l),
- ],
if (_bookQueueMode == 'manual' || _podcastQueueMode == 'manual') ...[
const SizedBox(height: 4),
SwitchListTile(
diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dart
index 4960df83..0c207b77 100644
--- a/lib/services/player_settings.dart
+++ b/lib/services/player_settings.dart
@@ -158,6 +158,10 @@ class PlayerSettings {
}
static Future<void> setBookQueueMode(String value) => _set('bookQueueMode', value, notify: true);
+ static Future<bool> getShowUpNextLabel() => _get('showUpNextLabel', true);
+ static Future<void> setShowUpNextLabel(bool value) =>
+ _set('showUpNextLabel', value, notify: true);
+
static Future<String> getPodcastQueueMode() async {
final value = await ScopedPrefs.getString('podcastQueueMode');
return value ?? await getQueueMode();
diff --git a/lib/widgets/playlist_detail_sheet.dart b/lib/widgets/playlist_detail_sheet.dart
index 8f20cf86..1c7df58c 100644
--- a/lib/widgets/playlist_detail_sheet.dart
+++ b/lib/widgets/playlist_detail_sheet.dart
@@ -10,6 +10,7 @@ import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
import '../services/audio_player_service.dart';
import '../services/download_service.dart';
+import '../screens/app_shell.dart';
import 'book_detail_sheet.dart';
import 'episode_list_sheet.dart';
import 'stackable_sheet.dart';
@@ -436,6 +437,7 @@ class _PlaylistDetailSheetState extends State<PlaylistDetailSheet> {
// expanded player on top of us and our pop closes it.
final playlistId = widget.playlistId;
Navigator.pop(context);
+ AppShell.goToAbsorbingGlobal();
await PlayerSettings.setQueueModePlaylist(playlistId);
await lib.playPlaylistFromStart(playlistId);
}