diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index 9027e562..807269d4 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -398,7 +398,7 @@ protected override void WndProc(ref Message m){ } } - if (isBrowserReady && m.Msg == NativeMethods.WM_PARENTNOTIFY && (m.WParam.ToInt32() & 0xFFFF) == NativeMethods.WM_XBUTTONDOWN){ + if (isBrowserReady && m.Msg == NativeMethods.WM_PARENTNOTIFY && (m.WParam.ToInt32() & 0xFFFF) == NativeMethods.WM_XBUTTONDOWN && !(videoPlayer?.Running ?? false)){ browser.ExecuteScriptAsync("TDGF_onMouseClickExtra", (m.WParam.ToInt32() >> 16) & 0xFFFF); return; } @@ -509,16 +509,16 @@ public void PlayNotificationSound(){ } public void PlayVideo(string url){ + if (string.IsNullOrEmpty(url)){ + videoPlayer?.Close(); + return; + } + if (videoPlayer == null){ videoPlayer = new VideoPlayer(this); } - - if (!string.IsNullOrEmpty(url)){ - videoPlayer.Launch(url); - } - else{ - videoPlayer.Close(); - } + + videoPlayer.Launch(url); } public void OnTweetScreenshotReady(string html, int width, int height){ diff --git a/Core/Other/Media/VideoPlayer.cs b/Core/Other/Media/VideoPlayer.cs index 5541e5dd..66f6b7f7 100644 --- a/Core/Other/Media/VideoPlayer.cs +++ b/Core/Other/Media/VideoPlayer.cs @@ -8,6 +8,17 @@ namespace TweetDuck.Core.Other.Media{ class VideoPlayer{ private readonly string PlayerExe = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe"); + public bool Running{ + get{ + if (currentProcess == null){ + return false; + } + + currentProcess.Refresh(); + return !currentProcess.HasExited; + } + } + private readonly Form owner; private Process currentProcess; private string lastUrl; diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 6633a524..07b8f99c 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -791,7 +791,7 @@ // (function(){ var playVideo = function(url){ - $('<div class="ovl" style="display:block"></div>').click(function(){ + $('<div class="ovl" style="display:block"></div>').on("click contextmenu", function(){ $TD.playVideo(null); $(this).remove(); }).appendTo(app);