Implemented AddChapters for convenience

Former-commit-id: e2dc91660c
This commit is contained in:
Weirdo 2021-12-21 00:40:45 +01:00
parent 5c8597670c
commit f38562aa68

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace FFMpegCore.Builders.MetaData
@ -19,6 +20,17 @@ public MetaDataBuilder AddChapter(ChapterData chapterData)
return this;
}
public MetaDataBuilder AddChapters<T>(IEnumerable<T> values, Func<T, (TimeSpan duration, string title)> chapterGetter)
{
foreach (T value in values)
{
var (duration, title) = chapterGetter(value);
AddChapter(duration, title);
}
return this;
}
public MetaDataBuilder AddChapter(TimeSpan duration, string? title = null)
{
var start = _metaData.Chapters.LastOrDefault()?.End ?? TimeSpan.Zero;