Skip to content

Commit

Permalink
Made the series play button play the next episode
Browse files Browse the repository at this point in the history
  • Loading branch information
beef331 committed Oct 10, 2023
1 parent 3c443e2 commit 60839c4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,48 @@ class PlaybackManager {
SortBy: options.shuffle ? 'Random' : 'SortName',
MediaTypes: 'Audio'
});
} else if (firstItem.Type === 'Series' || firstItem.Type === 'Season') {
const apiClient = ServerConnections.getApiClient(firstItem.ServerId);
promise = apiClient.getEpisodes(firstItem.SeriesId || firstItem.Id, {
IsVirtualUnaired: false,
IsMissing: false,
UserId: apiClient.getCurrentUserId(),
Fields: 'Chapters'
}).then(function (episodesResult) {
let foundItem = false;
const isSeries = firstItem.Type === 'Series';
const originalResults = episodesResult.Items;
episodesResult.Items = episodesResult.Items.filter(function (e) {
if (foundItem) {
return true;
}
if (!e.UserData.Played && (isSeries || e.SeasonId == firstItem.Id)) {
foundItem = true;
return true;
}

return false;
});

if (episodesResult.Items.length === 0) {
if (isSeries) {
episodesResult.Items = originalResults;
} else {
episodesResult.Items = originalResults.filter(function(e) {
if (foundItem) {
return true;
}
if (e.SeasonId == firstItem.Id) {
foundItem = true;
return true;
}
return false;
});
}
}
episodesResult.TotalRecordCount = episodesResult.Items.length;
return episodesResult;
});
} else if (firstItem.IsFolder && firstItem.CollectionType === 'homevideos') {
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
ParentId: firstItem.Id,
Expand Down

0 comments on commit 60839c4

Please sign in to comment.