fix: use continuous play queue for aired date episode order

close #756
This commit is contained in:
edde746
2026-03-25 23:28:57 +01:00
parent bfe35220aa
commit 8ff7676e60
2 changed files with 22 additions and 12 deletions
+11 -7
View File
@@ -934,15 +934,19 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
if (episodes.isEmpty) return;
// Sort by season then episode number, with Season 0 (Specials) at the end
// Sort by aired date, falling back to season/episode number
final sorted = List<PlexMetadata>.from(episodes)
..sort((a, b) {
final aIsSpecial = (a.parentIndex ?? 0) == 0;
final bIsSpecial = (b.parentIndex ?? 0) == 0;
if (aIsSpecial != bIsSpecial) return aIsSpecial ? 1 : -1;
final seasonCmp = (a.parentIndex ?? 0).compareTo(b.parentIndex ?? 0);
if (seasonCmp != 0) return seasonCmp;
return (a.index ?? 0).compareTo(b.index ?? 0);
final aDate = a.originallyAvailableAt ?? '';
final bDate = b.originallyAvailableAt ?? '';
if (aDate.isEmpty && bDate.isEmpty) {
final seasonCmp = (a.parentIndex ?? 0).compareTo(b.parentIndex ?? 0);
if (seasonCmp != 0) return seasonCmp;
return (a.index ?? 0).compareTo(b.index ?? 0);
}
if (aDate.isEmpty) return 1;
if (bDate.isEmpty) return -1;
return aDate.compareTo(bDate);
});
// Find current episode in the sorted list
+11 -5
View File
@@ -1981,21 +1981,27 @@ class PlexClient {
String? startingEpisodeKey,
}) async {
try {
// Get machine identifier for building the URI
final machineId = config.machineIdentifier ?? await getMachineIdentifier();
if (machineId == null) {
throw Exception('Could not get server machine identifier');
}
// Build the URI for the show's episodes
final uri = 'server://$machineId/com.plexapp.plugins.library/library/metadata/$showRatingKey/children';
// When starting from a specific episode, use continuous mode
// This lets the server determine playback order (respects episodeSort)
if (startingEpisodeKey != null && shuffle == 0) {
final uri = 'server://$machineId/com.plexapp.plugins.library/library/metadata/$startingEpisodeKey';
return await createPlayQueue(
uri: uri,
type: 'video',
continuous: 1,
);
}
// Create the play queue with optional starting episode
final uri = 'server://$machineId/com.plexapp.plugins.library/library/metadata/$showRatingKey/children';
return await createPlayQueue(
uri: uri,
type: 'video',
shuffle: shuffle,
key: startingEpisodeKey != null ? '/library/metadata/$startingEpisodeKey' : null,
);
} catch (e) {
appLogger.e('Failed to create show play queue', error: e);