mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Simplify video creation (and handle fallback better)
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
@ -14,21 +15,24 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public class TourneyVideo : CompositeDrawable
|
||||
{
|
||||
private readonly VideoSprite video;
|
||||
private readonly string filename;
|
||||
private readonly bool drawFallbackGradient;
|
||||
private VideoSprite video;
|
||||
|
||||
private readonly ManualClock manualClock;
|
||||
private ManualClock manualClock;
|
||||
|
||||
public TourneyVideo(Stream stream)
|
||||
public TourneyVideo(string filename, bool drawFallbackGradient = false)
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
InternalChild = new Box
|
||||
{
|
||||
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.3f), OsuColour.Gray(0.6f)),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
}
|
||||
else
|
||||
this.filename = filename;
|
||||
this.drawFallbackGradient = drawFallbackGradient;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(Storage storage)
|
||||
{
|
||||
var stream = storage.GetStream($@"videos/{filename}.m4v");
|
||||
|
||||
if (stream != null)
|
||||
{
|
||||
InternalChild = video = new VideoSprite(stream)
|
||||
{
|
||||
@ -37,6 +41,14 @@ namespace osu.Game.Tournament.Components
|
||||
Clock = new FramedClock(manualClock = new ManualClock())
|
||||
};
|
||||
}
|
||||
else if (drawFallbackGradient)
|
||||
{
|
||||
InternalChild = new Box
|
||||
{
|
||||
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.3f), OsuColour.Gray(0.6f)),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public bool Loop
|
||||
|
Reference in New Issue
Block a user