1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-08 04:17:24 +08:00

Merge pull request #6761 from peppy/fix-tournament-video-performance

Fix tournament videos stuttering when changing scenes
This commit is contained in:
Dan Balasescu 2019-11-08 17:46:50 +09:00 committed by GitHub
commit 4fc6aa940a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Colour;
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,8 @@ namespace osu.Game.Tournament.Components
{
private readonly VideoSprite video;
private readonly ManualClock manualClock;
public TourneyVideo(Stream stream)
{
if (stream == null)
@ -30,6 +33,7 @@ namespace osu.Game.Tournament.Components
{
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
Clock = new FramedClock(manualClock = new ManualClock())
};
}
@ -41,5 +45,17 @@ namespace osu.Game.Tournament.Components
video.Loop = value;
}
}
protected override void Update()
{
base.Update();
if (manualClock != null && Clock.ElapsedFrameTime < 100)
{
// 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 += Clock.ElapsedFrameTime;
}
}
}
}