mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-22 08:34:05 +02:00
Hide video player overlay when video process exits gracelessly
This commit is contained in:
parent
551dd229f5
commit
1e86a33ceb
@ -527,6 +527,7 @@ public void PlayVideo(string url){
|
|||||||
|
|
||||||
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 @@ public bool Running{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 @@ public void Close(){
|
|||||||
|
|
||||||
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 @@ private void process_Exited(object sender, EventArgs e){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentProcess.ExitCode != 0){
|
||||||
|
ProcessExitedGracelessly?.Invoke(this, new EventArgs());
|
||||||
|
}
|
||||||
|
|
||||||
currentProcess.Dispose();
|
currentProcess.Dispose();
|
||||||
currentProcess = null;
|
currentProcess = null;
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,11 @@
|
|||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user