@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user