Fix storyboard sample lifetimes not set if seeked past

This commit is contained in:
smoogipoo 2021-04-20 16:51:24 +09:00
parent 281c2041b2
commit d28eb399a4
1 changed files with 13 additions and 9 deletions

View File

@ -61,28 +61,32 @@ protected override void Update()
{
base.Update();
// Check if we've yet to pass the sample start time.
if (Time.Current < sampleInfo.StartTime)
{
// We've rewound before the start time of the sample
Stop();
// In the case that the user fast-forwards to a point far beyond the start time of the sample,
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
// Playback has stopped, but if the user fast-forwards to a point after the start time of the sample then
// we must not have a lifetime end in order to continue receiving updates and start the sample below.
LifetimeStart = sampleInfo.StartTime;
LifetimeEnd = double.MaxValue;
return;
}
else if (Time.Current - Time.Elapsed <= sampleInfo.StartTime)
// Ensure that we've elapsed from a point before the sample's start time before playing.
if (Time.Current - Time.Elapsed <= sampleInfo.StartTime)
{
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future
if (!RequestedPlaying && Time.Current - sampleInfo.StartTime < allowable_late_start)
Play();
// In the case that the user rewinds to a point far behind the start time of the sample,
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
LifetimeStart = double.MinValue;
LifetimeEnd = sampleInfo.StartTime;
}
// Playback has started, but if the user rewinds to a point before the start time of the sample then
// we must not have a lifetime start in order to continue receiving updates and stop the sample above.
LifetimeStart = double.MinValue;
LifetimeEnd = sampleInfo.StartTime;
}
}
}