var sampler = this.baseclip.GetSampler();
if (sampler == null)
{
return null;
}
var restTime = this.Duration - this.baseclip.Duration;
while (restTime > 0)
{
if (restTime >= this.baseclip.Duration)
{
sampler = sampler.FollowedBy(this.baseclip.GetSampler());
}
else
{
sampler = sampler.FollowedBy(
this.baseclip.GetSampler().Take(TimeSpan.FromSeconds(restTime))
);
}
restTime -= this.baseclip.Duration;
}
return sampler;
this.baseclip.GetSampler() would returns an ISamplerProvider from AudioFileReader.
And the duration of the source audio file is 7 seconds.
After I repeated it to 600 seconds by the codes above.
Then I use MediaFoundationEncoder.EncodeToAac with sampler.ToWaveProvider().
The result file is still with the duration of 7 seconds without repeating.
this.baseclip.GetSampler()
would returns anISamplerProvider
fromAudioFileReader
. And the duration of the source audio file is 7 seconds.After I repeated it to 600 seconds by the codes above. Then I use
MediaFoundationEncoder.EncodeToAac
withsampler.ToWaveProvider()
. The result file is still with the duration of 7 seconds without repeating.