|
|
|
@ -19,8 +19,24 @@ public class BlockPlayoutPreviewBuilder(
@@ -19,8 +19,24 @@ public class BlockPlayoutPreviewBuilder(
|
|
|
|
|
artistRepository, |
|
|
|
|
logger), IBlockPlayoutPreviewBuilder |
|
|
|
|
{ |
|
|
|
|
private readonly Dictionary<Guid, System.Collections.Generic.HashSet<CollectionKey>> _randomizedCollections = []; |
|
|
|
|
|
|
|
|
|
protected override ILogger Logger => NullLogger.Instance; |
|
|
|
|
|
|
|
|
|
public override async Task<Playout> Build( |
|
|
|
|
Playout playout, |
|
|
|
|
PlayoutBuildMode mode, |
|
|
|
|
CancellationToken cancellationToken) |
|
|
|
|
{ |
|
|
|
|
_randomizedCollections.Add(playout.Channel.UniqueId, []); |
|
|
|
|
|
|
|
|
|
Playout result = await base.Build(playout, mode, cancellationToken); |
|
|
|
|
|
|
|
|
|
_randomizedCollections.Remove(playout.Channel.UniqueId); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected override Task<int> GetDaysToBuild() => Task.FromResult(1); |
|
|
|
|
|
|
|
|
|
protected override IMediaCollectionEnumerator GetEnumerator( |
|
|
|
@ -30,16 +46,25 @@ public class BlockPlayoutPreviewBuilder(
@@ -30,16 +46,25 @@ public class BlockPlayoutPreviewBuilder(
|
|
|
|
|
string historyKey, |
|
|
|
|
Map<CollectionKey, List<MediaItem>> collectionMediaItems) |
|
|
|
|
{ |
|
|
|
|
IMediaCollectionEnumerator enumerator = base.GetEnumerator(playout, blockItem, currentTime, historyKey, collectionMediaItems); |
|
|
|
|
|
|
|
|
|
IMediaCollectionEnumerator enumerator = base.GetEnumerator( |
|
|
|
|
playout, |
|
|
|
|
blockItem, |
|
|
|
|
currentTime, |
|
|
|
|
historyKey, |
|
|
|
|
collectionMediaItems); |
|
|
|
|
|
|
|
|
|
var collectionKey = CollectionKey.ForBlockItem(blockItem); |
|
|
|
|
|
|
|
|
|
enumerator.ResetState( |
|
|
|
|
new CollectionEnumeratorState |
|
|
|
|
{ |
|
|
|
|
Seed = new Random().Next(), |
|
|
|
|
Index = new Random().Next(collectionMediaItems[collectionKey].Count) |
|
|
|
|
}); |
|
|
|
|
if (!_randomizedCollections[playout.Channel.UniqueId].Contains(collectionKey)) |
|
|
|
|
{ |
|
|
|
|
enumerator.ResetState( |
|
|
|
|
new CollectionEnumeratorState |
|
|
|
|
{ |
|
|
|
|
Seed = new Random().Next(), |
|
|
|
|
Index = new Random().Next(collectionMediaItems[collectionKey].Count) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
_randomizedCollections[playout.Channel.UniqueId].Add(collectionKey); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return enumerator; |
|
|
|
|
} |
|
|
|
|