From 5fe764b2db98b30113fdc9f2fc7690df8db97ed8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Nov 2019 16:19:34 +0900 Subject: [PATCH] Fix tournament videos stuttering when changing scenes --- .../Components/TourneyVideo.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/osu.Game.Tournament/Components/TourneyVideo.cs b/osu.Game.Tournament/Components/TourneyVideo.cs index 4f4660f645..f28a2773b6 100644 --- a/osu.Game.Tournament/Components/TourneyVideo.cs +++ b/osu.Game.Tournament/Components/TourneyVideo.cs @@ -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; + } } }