Fix tournament videos stuttering when changing scenes

This commit is contained in:
Dean Herbert 2019-11-08 16:19:34 +09:00
parent 6805c029e7
commit 5fe764b2db
1 changed files with 21 additions and 0 deletions

View File

@ -7,6 +7,7 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Video;
using osu.Framework.Timing;
using osu.Game.Graphics;
namespace osu.Game.Tournament.Components
@ -15,6 +16,9 @@ public class TourneyVideo : CompositeDrawable
{
private readonly VideoSprite video;
private ManualClock manualClock;
private IFrameBasedClock sourceClock;
public TourneyVideo(Stream stream)
{
if (stream == null)
@ -41,5 +45,22 @@ public bool Loop
video.Loop = value;
}
}
protected override void LoadComplete()
{
base.LoadComplete();
sourceClock = Clock;
Clock = new FramedClock(manualClock = new ManualClock());
}
protected override void Update()
{
base.Update();
// we want to avoid seeking as much as possible, because we care about performance, not sync.
// to avoid seeking completely, we only increment out local clock when in an updating state.
manualClock.CurrentTime += sourceClock.ElapsedFrameTime;
}
}
}