Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Show the podcast episode title, not just the show, when playing

Barnabas0b54d31b3772
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index de52b985..e0ecf010 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -2349,6 +2349,19 @@ class AudioPlayerService extends ChangeNotifier {
// source is loading (avoids briefly hearing the previous book).
await _player?.pause();
+ // Podcast episodes arrive two ways: episode-shaped (title = the episode)
+ // and show-shaped continue/queue entries (title = the show, episodeTitle =
+ // the episode, author often blank). Normalise to episode-as-title +
+ // show-as-artist so the episode shows everywhere — notification, lock
+ // screen, Android Auto, and the server listening session.
+ if (episodeId != null &&
+ episodeTitle != null &&
+ episodeTitle.isNotEmpty &&
+ episodeTitle != title) {
+ if (author.isEmpty) author = title; // `title` is the show name here
+ title = episodeTitle;
+ }
+
_isLoadingNewItem = true;
_api = api;
_currentItemId = itemId;
@@ -2767,6 +2780,8 @@ class AudioPlayerService extends ChangeNotifier {
mediaType: _currentEpisodeId != null ? 'podcast' : 'book',
duration: totalDuration,
startTime: startTime,
+ displayTitle: title,
+ displayAuthor: author,
);
Future.delayed(const Duration(milliseconds: 500), () {
_handler?.refreshPlaybackState();
@@ -3431,7 +3446,7 @@ class AudioPlayerService extends ChangeNotifier {
// (BT car display stuck on prior chapter). If this fires with fresh
// artist/chapter text but the car still shows old, the issue is downstream
// of audio_service's MediaSession push.
- debugPrint('[Handler] mediaItem.add: item=$itemId artist="$displayArtist" dur=${displayDuration.round()}s chapter=$chapter hasHandler=${_handler != null}');
+ debugPrint('[Handler] mediaItem.add: item=$itemId title="$title" artist="$displayArtist" dur=${displayDuration.round()}s chapter=$chapter hasHandler=${_handler != null}');
_handler!.mediaItem.add(MediaItem(
id: itemId,
title: title,
diff --git a/lib/services/local_session_service.dart b/lib/services/local_session_service.dart
index 842be4f3..36bc31c6 100644
--- a/lib/services/local_session_service.dart
+++ b/lib/services/local_session_service.dart
@@ -95,6 +95,8 @@ class LocalSessionService {
'libraryItemId': s['libraryItemId'],
'episodeId': s['episodeId'],
'mediaType': s['mediaType'],
+ 'displayTitle': s['displayTitle'],
+ 'displayAuthor': s['displayAuthor'],
'duration': s['duration'],
'startTime': s['startTime'],
'currentTime': s['currentTime'],
@@ -139,6 +141,8 @@ class LocalSessionService {
required String mediaType,
required double duration,
required double startTime,
+ String? displayTitle,
+ String? displayAuthor,
}) async {
await _loadActive();
final now = clock();
@@ -171,6 +175,10 @@ class LocalSessionService {
'updatedAt': nowMs,
'date': today,
'dayOfWeek': _dayOfWeek(now),
+ // Sent so the server session shows the episode (for podcasts) rather than
+ // defaulting to the library item title (the show). Books send their title.
+ 'displayTitle': displayTitle,
+ 'displayAuthor': displayAuthor,
};
await _persistActive();
debugPrint('[LocalSession] Began session ${_active!['id']} for $progressKey ($today)');
@@ -226,6 +234,8 @@ class LocalSessionService {
'updatedAt': nowMs,
'date': today,
'dayOfWeek': _dayOfWeek(effective),
+ 'displayTitle': old['displayTitle'],
+ 'displayAuthor': old['displayAuthor'],
};
// Ship the just-closed day promptly when online.
if (api != null) await flushPending(api: api);