2019-06-17 20:07:30 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Video;
|
2019-11-08 15:19:34 +08:00
|
|
|
using osu.Framework.Timing;
|
2019-06-17 20:07:30 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Components
|
|
|
|
{
|
|
|
|
public class TourneyVideo : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly VideoSprite video;
|
|
|
|
|
2019-11-08 16:13:45 +08:00
|
|
|
private readonly ManualClock manualClock;
|
2019-11-08 15:19:34 +08:00
|
|
|
|
2019-06-17 20:07:30 +08:00
|
|
|
public TourneyVideo(Stream stream)
|
|
|
|
{
|
|
|
|
if (stream == null)
|
|
|
|
{
|
|
|
|
InternalChild = new Box
|
|
|
|
{
|
|
|
|
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.3f), OsuColour.Gray(0.6f)),
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
2019-11-11 19:53:22 +08:00
|
|
|
{
|
2019-06-17 20:07:30 +08:00
|
|
|
InternalChild = video = new VideoSprite(stream)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
FillMode = FillMode.Fit,
|
2019-11-08 16:13:45 +08:00
|
|
|
Clock = new FramedClock(manualClock = new ManualClock())
|
2019-06-17 20:07:30 +08:00
|
|
|
};
|
2019-11-11 19:53:22 +08:00
|
|
|
}
|
2019-06-17 20:07:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool Loop
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (video != null)
|
|
|
|
video.Loop = value;
|
|
|
|
}
|
|
|
|
}
|
2019-11-08 15:19:34 +08:00
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
2019-11-08 16:13:45 +08:00
|
|
|
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;
|
|
|
|
}
|
2019-11-08 15:19:34 +08:00
|
|
|
}
|
2019-06-17 20:07:30 +08:00
|
|
|
}
|
|
|
|
}
|