1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-20 09:49:46 +02:00

Hide video player overlay when video process exits gracelessly

This commit is contained in:
2017-08-12 03:12:50 +02:00
parent 551dd229f5
commit 1e86a33ceb
3 changed files with 14 additions and 6 deletions
Core
video/TweetDuck.Video

@@ -527,6 +527,7 @@ namespace TweetDuck.Core{
if (videoPlayer == null){ if (videoPlayer == null){
videoPlayer = new VideoPlayer(this); videoPlayer = new VideoPlayer(this);
videoPlayer.ProcessExitedGracelessly += (sender, args) => HideVideoOverlay();
} }
videoPlayer.Launch(url); videoPlayer.Launch(url);

@@ -19,6 +19,8 @@ namespace TweetDuck.Core.Other.Management{
} }
} }
public event EventHandler ProcessExitedGracelessly;
private readonly Form owner; private readonly Form owner;
private Process currentProcess; private Process currentProcess;
private string lastUrl; private string lastUrl;
@@ -69,14 +71,14 @@ namespace TweetDuck.Core.Other.Management{
private void process_Exited(object sender, EventArgs e){ private void process_Exited(object sender, EventArgs e){
switch(currentProcess.ExitCode){ 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)){ 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); BrowserUtils.OpenExternalBrowser(lastUrl);
} }
break; 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)){ 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); BrowserUtils.OpenExternalBrowser(lastUrl);
} }
@@ -84,6 +86,10 @@ namespace TweetDuck.Core.Other.Management{
break; break;
} }
if (currentProcess.ExitCode != 0){
ProcessExitedGracelessly?.Invoke(this, new EventArgs());
}
currentProcess.Dispose(); currentProcess.Dispose();
currentProcess = null; currentProcess = null;
} }

@@ -5,10 +5,11 @@ using System.Windows.Forms;
namespace TweetDuck.Video{ namespace TweetDuck.Video{
static class Program{ static class Program{
// referenced in VideoPlayer // referenced in VideoPlayer
public const int CODE_INVALID_ARGS = 1; // set by task manager -- public const int CODE_PROCESS_KILLED = 1;
public const int CODE_LAUNCH_FAIL = 2; public const int CODE_INVALID_ARGS = 2;
public const int CODE_MEDIA_ERROR = 3; public const int CODE_LAUNCH_FAIL = 3;
public const int CODE_OWNER_GONE = 4; public const int CODE_MEDIA_ERROR = 4;
public const int CODE_OWNER_GONE = 5;
private static uint? message; private static uint? message;
public static uint VideoPlayerMessage => message ?? (message = NativeMethods.RegisterWindowMessage("TweetDuckVideoPlayer")).Value; public static uint VideoPlayerMessage => message ?? (message = NativeMethods.RegisterWindowMessage("TweetDuckVideoPlayer")).Value;