From eaf3dca607d5b3906744cbabdb25c138d073c2d1 Mon Sep 17 00:00:00 2001 From: niksedk Date: Tue, 8 Feb 2011 17:42:32 +0000 Subject: [PATCH] vlcLib player - only toggle play/pause on mouse click when form is active git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@324 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Logic/VideoPlayers/LibVlcDynamic.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Logic/VideoPlayers/LibVlcDynamic.cs b/src/Logic/VideoPlayers/LibVlcDynamic.cs index 969cb77e2..ba9a5ac75 100644 --- a/src/Logic/VideoPlayers/LibVlcDynamic.cs +++ b/src/Logic/VideoPlayers/LibVlcDynamic.cs @@ -18,6 +18,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers private IntPtr _libVlc; private IntPtr _mediaPlayer; private System.Windows.Forms.Control _ownerControl; + private System.Windows.Forms.Form _parentForm; [DllImport("user32")] private static extern short GetKeyState(int vKey); @@ -346,6 +347,8 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers newVlc._libVlc = this._libVlc; newVlc._libVlcDLL = this._libVlcDLL; newVlc._ownerControl = ownerControl; + if (ownerControl != null) + newVlc._parentForm = ownerControl.FindForm(); newVlc.LoadLibVlcDynamic(); @@ -444,6 +447,8 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers public override void Initialize(System.Windows.Forms.Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) { _ownerControl = ownerControl; + if (ownerControl != null) + _parentForm = ownerControl.FindForm(); string dllFile = GetVlcPath("libvlc.dll"); if (File.Exists(dllFile)) { @@ -497,7 +502,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers void MouseTimerTick(object sender, EventArgs e) { _mouseTimer.Stop(); - if (IsLeftMouseButtonDown()) + if (_parentForm != null && _parentForm.ContainsFocus && IsLeftMouseButtonDown()) { var p = _ownerControl.PointToClient(System.Windows.Forms.Control.MousePosition); if (p.X > 0 && p.X < _ownerControl.Width && p.Y > 0 && p.Y < _ownerControl.Height) @@ -507,9 +512,9 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers else Play(); int i = 0; - while (IsLeftMouseButtonDown() && i < 20) + while (IsLeftMouseButtonDown() && i < 200) { - System.Threading.Thread.Sleep(25); + System.Threading.Thread.Sleep(2); System.Windows.Forms.Application.DoEvents(); i++; }