add duration discard to fill attempts (#1301)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using ErsatzTV.Core.Domain;
|
||||
using ErsatzTV.Core.Extensions;
|
||||
using ErsatzTV.Core.Interfaces.Scheduling;
|
||||
|
||||
namespace ErsatzTV.Core.Scheduling;
|
||||
@@ -6,6 +7,7 @@ namespace ErsatzTV.Core.Scheduling;
|
||||
public class CustomOrderCollectionEnumerator : IMediaCollectionEnumerator
|
||||
{
|
||||
private readonly IList<MediaItem> _sortedMediaItems;
|
||||
private readonly Lazy<Option<TimeSpan>> _lazyMinimumDuration;
|
||||
|
||||
public CustomOrderCollectionEnumerator(
|
||||
Collection collection,
|
||||
@@ -17,6 +19,8 @@ public class CustomOrderCollectionEnumerator : IMediaCollectionEnumerator
|
||||
.OrderBy(ci => ci.CustomIndex)
|
||||
.Map(ci => mediaItems.First(mi => mi.Id == ci.MediaItemId))
|
||||
.ToList();
|
||||
_lazyMinimumDuration = new Lazy<Option<TimeSpan>>(
|
||||
() => _sortedMediaItems.Bind(i => i.GetDuration()).HeadOrNone());
|
||||
|
||||
State = new CollectionEnumeratorState { Seed = state.Seed };
|
||||
while (State.Index < state.Index)
|
||||
@@ -33,4 +37,6 @@ public class CustomOrderCollectionEnumerator : IMediaCollectionEnumerator
|
||||
|
||||
public Option<MediaItem> Peek(int offset) =>
|
||||
throw new NotSupportedException();
|
||||
|
||||
public Option<TimeSpan> MinimumDuration => _lazyMinimumDuration.Value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user