Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the series and season Play button play the next episode #4827

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,56 @@ 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) {
const originalResults = episodesResult.Items;
const isSeries = firstItem.Type === 'Series';

let foundItem = false;

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
Loading