mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 23:17:18 +08:00
implement video parsing
This commit is contained in:
parent
49fb21ffa9
commit
6e5cb8a318
@ -13,6 +13,7 @@ using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
@ -340,6 +341,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
protected override IBeatmap GetBeatmap() => beatmap;
|
||||
protected override Texture GetBackground() => null;
|
||||
protected override VideoSprite GetVideo() => null;
|
||||
protected override Track GetTrack() => null;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
@ -64,6 +65,21 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
}
|
||||
|
||||
protected override VideoSprite GetVideo()
|
||||
{
|
||||
if (Metadata?.VideoFile == null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
return new VideoSprite(textureStore.GetStream(getPathForFile(Metadata.VideoFile)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Track GetTrack()
|
||||
{
|
||||
try
|
||||
|
@ -52,6 +52,7 @@ namespace osu.Game.Beatmaps
|
||||
public int PreviewTime { get; set; }
|
||||
public string AudioFile { get; set; }
|
||||
public string BackgroundFile { get; set; }
|
||||
public string VideoFile { get; set; }
|
||||
|
||||
public override string ToString() => $"{Artist} - {Title} ({Author})";
|
||||
|
||||
@ -81,7 +82,8 @@ namespace osu.Game.Beatmaps
|
||||
&& Tags == other.Tags
|
||||
&& PreviewTime == other.PreviewTime
|
||||
&& AudioFile == other.AudioFile
|
||||
&& BackgroundFile == other.BackgroundFile;
|
||||
&& BackgroundFile == other.BackgroundFile
|
||||
&& VideoFile == other.VideoFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -44,6 +45,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
protected override Texture GetBackground() => textures?.Get(@"Backgrounds/bg4");
|
||||
|
||||
protected override VideoSprite GetVideo() => null;
|
||||
|
||||
protected override Track GetTrack() => GetVirtualTrack();
|
||||
|
||||
private class DummyRulesetInfo : RulesetInfo
|
||||
|
@ -296,8 +296,13 @@ namespace osu.Game.Beatmaps.Formats
|
||||
switch (type)
|
||||
{
|
||||
case EventType.Background:
|
||||
string filename = split[2].Trim('"');
|
||||
beatmap.BeatmapInfo.Metadata.BackgroundFile = FileSafety.PathStandardise(filename);
|
||||
string bgFilename = split[2].Trim('"');
|
||||
beatmap.BeatmapInfo.Metadata.BackgroundFile = FileSafety.PathStandardise(bgFilename);
|
||||
break;
|
||||
|
||||
case EventType.Video:
|
||||
string videoFilename = split[2].Trim('"');
|
||||
beatmap.BeatmapInfo.Metadata.VideoFile = FileSafety.PathStandardise(videoFilename);
|
||||
break;
|
||||
|
||||
case EventType.Break:
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -25,6 +26,11 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
Texture Background { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the video file for this <see cref="WorkingBeatmap"/>.
|
||||
/// </summary>
|
||||
VideoSprite Video { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the audio track for this <see cref="WorkingBeatmap"/>.
|
||||
/// </summary>
|
||||
|
@ -19,6 +19,7 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Framework.Graphics.Video;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -43,6 +44,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
track = new RecyclableLazy<Track>(() => GetTrack() ?? GetVirtualTrack());
|
||||
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
|
||||
video = new RecyclableLazy<VideoSprite>(GetVideo);
|
||||
waveform = new RecyclableLazy<Waveform>(GetWaveform);
|
||||
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
|
||||
skin = new RecyclableLazy<ISkin>(GetSkin);
|
||||
@ -183,9 +185,16 @@ namespace osu.Game.Beatmaps
|
||||
public bool BackgroundLoaded => background.IsResultAvailable;
|
||||
public Texture Background => background.Value;
|
||||
protected virtual bool BackgroundStillValid(Texture b) => b == null || b.Available;
|
||||
|
||||
protected abstract Texture GetBackground();
|
||||
private readonly RecyclableLazy<Texture> background;
|
||||
|
||||
public bool VideoLoaded => video.IsResultAvailable;
|
||||
public VideoSprite Video => video.Value;
|
||||
|
||||
protected abstract VideoSprite GetVideo();
|
||||
private readonly RecyclableLazy<VideoSprite> video;
|
||||
|
||||
public bool TrackLoaded => track.IsResultAvailable;
|
||||
public Track Track => track.Value;
|
||||
protected abstract Track GetTrack();
|
||||
|
@ -123,6 +123,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -35,6 +35,7 @@ namespace osu.Game.Migrations
|
||||
AudioFile = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Author = table.Column<string>(type: "TEXT", nullable: true),
|
||||
BackgroundFile = table.Column<string>(type: "TEXT", nullable: true),
|
||||
VideoFile = table.Column<string>(type: "TEXT", nullable: true),
|
||||
PreviewTime = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Source = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Tags = table.Column<string>(type: "TEXT", nullable: true),
|
||||
|
@ -125,6 +125,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -128,6 +128,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -128,6 +128,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -128,6 +128,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -128,6 +128,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -126,6 +126,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -125,6 +125,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -125,6 +125,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -127,6 +127,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -127,6 +127,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -15,6 +15,7 @@ namespace osu.Game.Migrations
|
||||
migrationBuilder.Sql($"UPDATE `BeatmapInfo` SET `Path` = REPLACE(`Path`, '{windowsStyle}', '{standardized}')");
|
||||
migrationBuilder.Sql($"UPDATE `BeatmapMetadata` SET `AudioFile` = REPLACE(`AudioFile`, '{windowsStyle}', '{standardized}')");
|
||||
migrationBuilder.Sql($"UPDATE `BeatmapMetadata` SET `BackgroundFile` = REPLACE(`BackgroundFile`, '{windowsStyle}', '{standardized}')");
|
||||
migrationBuilder.Sql($"UPDATE `BeatmapMetadata` SET `VideoFile` = REPLACE(`VideoFile`, '{windowsStyle}', '{standardized}')");
|
||||
migrationBuilder.Sql($"UPDATE `BeatmapSetFileInfo` SET `Filename` = REPLACE(`Filename`, '{windowsStyle}', '{standardized}')");
|
||||
migrationBuilder.Sql($"UPDATE `SkinFileInfo` SET `Filename` = REPLACE(`Filename`, '{windowsStyle}', '{standardized}')");
|
||||
}
|
||||
|
@ -127,6 +127,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -127,6 +127,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -127,6 +127,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -127,6 +127,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -127,6 +127,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -131,6 +131,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -129,6 +129,8 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<string>("VideoFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -33,6 +34,8 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public Texture Background => workingBeatmap.Background;
|
||||
|
||||
public VideoSprite Video => workingBeatmap.Video;
|
||||
|
||||
public Track Track => workingBeatmap.Track;
|
||||
|
||||
public Waveform Waveform => workingBeatmap.Waveform;
|
||||
|
@ -10,6 +10,7 @@ using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Rulesets;
|
||||
@ -201,6 +202,8 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
protected override Texture GetBackground() => throw new NotImplementedException();
|
||||
|
||||
protected override VideoSprite GetVideo() => throw new NotImplementedException();
|
||||
|
||||
protected override Track GetTrack() => throw new NotImplementedException();
|
||||
|
||||
protected override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset)
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Beatmaps
|
||||
@ -25,6 +26,8 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
protected override Texture GetBackground() => null;
|
||||
|
||||
protected override VideoSprite GetVideo() => null;
|
||||
|
||||
protected override Track GetTrack() => null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user