| | | 1 | | using System; |
| | | 2 | | using MediaBrowser.Controller.Entities; |
| | | 3 | | using MediaBrowser.Model.Dto; |
| | | 4 | | |
| | | 5 | | namespace MediaBrowser.Controller.Library |
| | | 6 | | { |
| | | 7 | | /// <summary> |
| | | 8 | | /// The user data of the most recently played alternate version that should drive the completion state of a multi-ve |
| | | 9 | | /// </summary> |
| | | 10 | | /// <param name="VersionId">The id of the version that owns <paramref name="UserData"/>.</param> |
| | | 11 | | /// <param name="UserData">The resume version's user data.</param> |
| | | 12 | | public record VersionResumeData(Guid VersionId, UserItemData UserData) |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Merges the most recently played version's completion state into the supplied user data dto. |
| | | 16 | | /// Completion (played) propagates to the primary. An in-progress resume position stays on the version |
| | | 17 | | /// that owns it, which is surfaced directly (e.g. in resume queries) so that playback always targets |
| | | 18 | | /// the correct version rather than resuming the primary at another version's offset. When the movie was |
| | | 19 | | /// finished on a different version, the primary's own stale resume position is cleared so it does not |
| | | 20 | | /// render as "watched and resumable" at the same time. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="dto">The user data dto to update.</param> |
| | | 23 | | public void ApplyTo(UserItemDataDto dto) |
| | | 24 | | { |
| | 4 | 25 | | dto.Played = dto.Played || UserData.Played; |
| | | 26 | | |
| | 4 | 27 | | if ((UserData.LastPlayedDate ?? DateTime.MinValue) > (dto.LastPlayedDate ?? DateTime.MinValue)) |
| | | 28 | | { |
| | 3 | 29 | | dto.LastPlayedDate = UserData.LastPlayedDate; |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | // A different version was finished (played, no resume position of its own) and is the most |
| | | 33 | | // recently played: the whole movie is watched. |
| | 4 | 34 | | if (!VersionId.Equals(dto.ItemId) && UserData.Played && UserData.PlaybackPositionTicks <= 0) |
| | | 35 | | { |
| | 1 | 36 | | dto.PlaybackPositionTicks = 0; |
| | 1 | 37 | | dto.PlayedPercentage = null; |
| | | 38 | | } |
| | 4 | 39 | | } |
| | | 40 | | } |
| | | 41 | | } |