Stream custom live channels using your own media
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
1.1 KiB

using ErsatzTV.Core.Scheduling.YamlScheduling.Models;
using Microsoft.Extensions.Logging;
namespace ErsatzTV.Core.Scheduling.YamlScheduling.Handlers;
public class YamlPlayoutRepeatHandler : IYamlPlayoutHandler
{
private int _itemsSinceLastRepeat;
public bool Reset => false;
public Task<bool> Handle(
YamlPlayoutContext context,
YamlPlayoutInstruction instruction,
PlayoutBuildMode mode,
ILogger<YamlPlayoutBuilder> logger,
CancellationToken cancellationToken)
{
if (instruction is not YamlPlayoutRepeatInstruction)
{
return Task.FromResult(false);
}
if (context.VisitedAll && _itemsSinceLastRepeat == context.Playout.Items.Count)
{
logger.LogWarning("Repeat encountered without adding any playout items; aborting");
throw new InvalidOperationException("YAML playout loop detected");
}
_itemsSinceLastRepeat = context.Playout.Items.Count;
context.InstructionIndex = 0;
return Task.FromResult(true);
}
}