Unify MediaGlobal/Scripting.Media PlayFMV* methods
- Improve consistency - Remove dead code - Removed AsyncAction! - Delegate.BeginInvoke is unsupported since .NET Core and throws an "Operation is not supported on this platform." exception.
This commit is contained in:
@@ -12,21 +12,20 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using OpenRA.Mods.Common.Widgets;
|
||||
using OpenRA.Video;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
public static class Media
|
||||
{
|
||||
public static void PlayFMVFullscreen(World w, string movie, Action onComplete)
|
||||
public static void PlayFMVFullscreen(World w, string videoFileName, Action onComplete)
|
||||
{
|
||||
var playerRoot = Game.OpenWindow(w, "FMVPLAYER");
|
||||
var player = playerRoot.Get<VideoPlayerWidget>("PLAYER");
|
||||
|
||||
try
|
||||
{
|
||||
player.Load(movie);
|
||||
player.Load(videoFileName);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
@@ -60,10 +59,19 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
});
|
||||
}
|
||||
|
||||
public static void PlayFMVInRadar(IVideo movie, Action onComplete)
|
||||
public static void PlayFMVInRadar(string videoFileName, Action onComplete)
|
||||
{
|
||||
var player = Ui.Root.Get<VideoPlayerWidget>("PLAYER");
|
||||
player.Open(movie);
|
||||
|
||||
try
|
||||
{
|
||||
player.Load(videoFileName);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
player.PlayThen(() =>
|
||||
{
|
||||
@@ -71,16 +79,5 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
player.CloseVideo();
|
||||
});
|
||||
}
|
||||
|
||||
public static void StopFMVInRadar()
|
||||
{
|
||||
var player = Ui.Root.Get<VideoPlayerWidget>("PLAYER");
|
||||
player.Stop();
|
||||
}
|
||||
|
||||
public static IVideo LoadVideo(Stream s)
|
||||
{
|
||||
return VideoLoader.GetVideo(s, true, Game.ModData.VideoLoaders);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user