diff --git a/OpenRA.Mods.Cnc/VideoLoaders/VqaLoader.cs b/OpenRA.Mods.Cnc/VideoLoaders/VqaLoader.cs index 6eb88afe55..8030ba637f 100644 --- a/OpenRA.Mods.Cnc/VideoLoaders/VqaLoader.cs +++ b/OpenRA.Mods.Cnc/VideoLoaders/VqaLoader.cs @@ -21,6 +21,9 @@ namespace OpenRA.Mods.Cnc.VideoLoaders { video = null; + if (s.Length == 0) + return false; + if (!IsWestwoodVqa(s)) return false; @@ -28,7 +31,7 @@ namespace OpenRA.Mods.Cnc.VideoLoaders return true; } - bool IsWestwoodVqa(Stream s) + static bool IsWestwoodVqa(Stream s) { var start = s.Position; diff --git a/OpenRA.Mods.Cnc/VideoLoaders/WsaLoader.cs b/OpenRA.Mods.Cnc/VideoLoaders/WsaLoader.cs index 9359354f42..646933ecf8 100644 --- a/OpenRA.Mods.Cnc/VideoLoaders/WsaLoader.cs +++ b/OpenRA.Mods.Cnc/VideoLoaders/WsaLoader.cs @@ -22,6 +22,9 @@ namespace OpenRA.Mods.Cnc.VideoLoaders { video = null; + if (s.Length == 0) + return false; + if (!IsWsa(s)) return false; @@ -29,7 +32,7 @@ namespace OpenRA.Mods.Cnc.VideoLoaders return true; } - bool IsWsa(Stream s) + static bool IsWsa(Stream s) { var start = s.Position; diff --git a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs index be6e32455d..b63cfa36d6 100644 --- a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs @@ -170,7 +170,7 @@ namespace OpenRA.Mods.Common.Scripting } catch (FileNotFoundException e) { - Log.Write("lua", "Couldn't play movie {0}! File doesn't exist.", e.FileName); + Log.Write("lua", $"Couldn't play movie {e.FileName}! File doesn't exist."); onCompleteRadar(); return false; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs index deb4229668..ca83cf0740 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs @@ -343,15 +343,28 @@ namespace OpenRA.Mods.Common.Widgets.Logic playingVideo = pv; player.Load(video); - // video playback runs asynchronously - player.PlayThen(() => + if (player.Video == null) { StopVideo(player); - onComplete?.Invoke(); - }); - // Mute other distracting sounds - MuteSounds(); + ConfirmationDialogs.ButtonPrompt( + title: "Unable to play video", + text: "Something went wrong during video playback.", + cancelText: "Back", + onCancel: () => { }); + } + else + { + // video playback runs asynchronously + player.PlayThen(() => + { + StopVideo(player); + onComplete?.Invoke(); + }); + + // Mute other distracting sounds + MuteSounds(); + } } } diff --git a/OpenRA.Mods.Common/Widgets/VideoPlayerWidget.cs b/OpenRA.Mods.Common/Widgets/VideoPlayerWidget.cs index e3eb1c19d1..d067c479b6 100644 --- a/OpenRA.Mods.Common/Widgets/VideoPlayerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/VideoPlayerWidget.cs @@ -46,7 +46,8 @@ namespace OpenRA.Mods.Common.Widgets if (filename == cachedVideoFileName) return; - var video = VideoLoader.GetVideo(Game.ModData.DefaultFileSystem.Open(filename), true, Game.ModData.VideoLoaders); + var stream = Game.ModData.DefaultFileSystem.Open(filename); + var video = VideoLoader.GetVideo(stream, true, Game.ModData.VideoLoaders); Open(video); cachedVideoFileName = filename; @@ -56,6 +57,9 @@ namespace OpenRA.Mods.Common.Widgets { this.video = video; + if (video == null) + return; + stopped = true; paused = true; Game.Sound.StopVideo();