diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index 879ec6c3..728e7a21 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -527,6 +527,7 @@ public void PlayVideo(string url){ if (videoPlayer == null){ videoPlayer = new VideoPlayer(this); + videoPlayer.ProcessExitedGracelessly += (sender, args) => HideVideoOverlay(); } videoPlayer.Launch(url); diff --git a/Core/Other/Management/VideoPlayer.cs b/Core/Other/Management/VideoPlayer.cs index 0e946e84..2314cbd5 100644 --- a/Core/Other/Management/VideoPlayer.cs +++ b/Core/Other/Management/VideoPlayer.cs @@ -19,6 +19,8 @@ public bool Running{ } } + public event EventHandler ProcessExitedGracelessly; + private readonly Form owner; private Process currentProcess; private string lastUrl; @@ -69,14 +71,14 @@ public void Close(){ private void process_Exited(object sender, EventArgs e){ switch(currentProcess.ExitCode){ - case 2: // CODE_LAUNCH_FAIL + case 3: // CODE_LAUNCH_FAIL if (FormMessage.Error("Video Playback Error", "Error launching video player, this may be caused by missing Windows Media Player. Do you want to open the video in a browser?", FormMessage.Yes, FormMessage.No)){ BrowserUtils.OpenExternalBrowser(lastUrl); } break; - case 3: // CODE_MEDIA_ERROR + case 4: // CODE_MEDIA_ERROR if (FormMessage.Error("Video Playback Error", "The video could not be loaded, most likely due to unknown format. Do you want to open the video in a browser?", FormMessage.Yes, FormMessage.No)){ BrowserUtils.OpenExternalBrowser(lastUrl); } @@ -84,6 +86,10 @@ private void process_Exited(object sender, EventArgs e){ break; } + if (currentProcess.ExitCode != 0){ + ProcessExitedGracelessly?.Invoke(this, new EventArgs()); + } + currentProcess.Dispose(); currentProcess = null; } diff --git a/video/TweetDuck.Video/Program.cs b/video/TweetDuck.Video/Program.cs index fb8d7dce..8df373aa 100644 --- a/video/TweetDuck.Video/Program.cs +++ b/video/TweetDuck.Video/Program.cs @@ -5,10 +5,11 @@ namespace TweetDuck.Video{ static class Program{ // referenced in VideoPlayer - public const int CODE_INVALID_ARGS = 1; - public const int CODE_LAUNCH_FAIL = 2; - public const int CODE_MEDIA_ERROR = 3; - public const int CODE_OWNER_GONE = 4; + // set by task manager -- public const int CODE_PROCESS_KILLED = 1; + public const int CODE_INVALID_ARGS = 2; + public const int CODE_LAUNCH_FAIL = 3; + public const int CODE_MEDIA_ERROR = 4; + public const int CODE_OWNER_GONE = 5; private static uint? message; public static uint VideoPlayerMessage => message ?? (message = NativeMethods.RegisterWindowMessage("TweetDuckVideoPlayer")).Value;