Browse Source

use playlist item count when playlists are used as filler (#2716)

* use playlist item count when playlists are used as filler

* expand test
pull/2718/head
Jason Dove 3 weeks ago committed by GitHub
parent
commit
038286c92b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 72
      ErsatzTV.Core.Tests/Scheduling/PlaylistEnumeratorTests.cs
  3. 2
      ErsatzTV.Core/Scheduling/PlaylistEnumerator.cs

1
CHANGELOG.md

@ -52,6 +52,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- fix green padding when encoding h264 using main profile - fix green padding when encoding h264 using main profile
- Automatically kill playback troubleshooting ffmpeg process if it hasn't completed after two minutes - Automatically kill playback troubleshooting ffmpeg process if it hasn't completed after two minutes
- Fix playback of certain BT.2020 content - Fix playback of certain BT.2020 content
- Use playlist item count when using a playlist as filler (instead of a fixed count of 1 for each playlist item)
### Changed ### Changed
- No longer round framerate to nearest integer when normalizing framerate - No longer round framerate to nearest integer when normalizing framerate

72
ErsatzTV.Core.Tests/Scheduling/PlaylistEnumeratorTests.cs

@ -285,6 +285,78 @@ public class PlaylistEnumeratorTests
items.ShouldBe([20, 30, 10, 11]); items.ShouldBe([20, 30, 10, 11]);
} }
[Test]
public async Task CountForFiller_Should_Honor_Custom_Count_And_PlayAll()
{
// this isn't needed for chronological, so no need to implement anything
IMediaCollectionRepository repo = Substitute.For<IMediaCollectionRepository>();
var playlistItemMap = new Dictionary<PlaylistItem, List<MediaItem>>
{
{
new PlaylistItem
{
Id = 1,
Index = 0,
PlaybackOrder = PlaybackOrder.Chronological,
PlayAll = false,
Count = 2,
CollectionType = CollectionType.Collection,
CollectionId = 1
},
[FakeMovie(10), FakeMovie(11), FakeMovie(12)]
},
{
new PlaylistItem
{
Id = 2,
Index = 1,
PlaybackOrder = PlaybackOrder.Chronological,
PlayAll = false,
CollectionType = CollectionType.Collection,
CollectionId = 2
},
[FakeMovie(15)]
},
{
new PlaylistItem
{
Id = 3,
Index = 2,
PlaybackOrder = PlaybackOrder.Chronological,
PlayAll = false,
CollectionType = CollectionType.Collection,
CollectionId = 3
},
[FakeMovie(20)]
},
{
new PlaylistItem
{
Id = 4,
Index = 3,
PlaybackOrder = PlaybackOrder.Chronological,
PlayAll = true,
CollectionType = CollectionType.Collection,
CollectionId = 4
},
[FakeMovie(25), FakeMovie(26), FakeMovie(27)]
}
};
var state = new CollectionEnumeratorState { Seed = 1 };
PlaylistEnumerator enumerator = await PlaylistEnumerator.Create(
repo,
playlistItemMap,
state,
shufflePlaylistItems: true,
batchSize: Option<int>.None,
CancellationToken.None);
enumerator.CountForFiller.ShouldBe(7);
}
private static Movie FakeMovie(int id) => new() private static Movie FakeMovie(int id) => new()
{ {
Id = id, Id = id,

2
ErsatzTV.Core/Scheduling/PlaylistEnumerator.cs

@ -23,7 +23,7 @@ public class PlaylistEnumerator : IMediaCollectionEnumerator
public int CountForRandom => _allMediaItemIds.Count; public int CountForRandom => _allMediaItemIds.Count;
public int CountForFiller => _sortedEnumerators.Select(t => t.PlayAll ? t.Enumerator.Count : 1).Sum(); public int CountForFiller => _sortedEnumerators.Select(t => t.PlayAll ? t.Enumerator.Count : t.Count ?? 1).Sum();
public ImmutableList<PlaylistEnumeratorCollectionKey> ChildEnumerators { get; private set; } public ImmutableList<PlaylistEnumeratorCollectionKey> ChildEnumerators { get; private set; }

Loading…
Cancel
Save