diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 05117fd08d90..c6e57812668c 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -1848,6 +1848,34 @@ 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' + 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) { + // TODO: Reset Watch Status and add all + } + episodesResult.TotalRecordCount = episodesResult.Items.length; + return episodesResult; + }); } else if (firstItem.IsFolder && firstItem.CollectionType === 'homevideos') { promise = getItemsForPlayback(serverId, mergePlaybackQueries({ ParentId: firstItem.Id,