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 8, 2023
1 parent 3c443e2 commit 10bb08a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,51 @@ 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) {
const userId = apiClient.getCurrentUserId()
if (isSeries) {
episodesResult.Items = originalResults;
apiClient.markUnplayed(userId, firstItem.Id, {});
} else {
apiClient.markUnplayed(userId, firstItem.Id, {});
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 10bb08a

Please sign in to comment.