try to fix #413
This commit is contained in:
@@ -71,7 +71,6 @@ namespace mpvnet
|
||||
public List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
|
||||
public List<TimeSpan> BluRayTitles { get; } = new List<TimeSpan>();
|
||||
public IntPtr Handle { get; set; }
|
||||
public IntPtr WindowHandle { get; set; }
|
||||
|
||||
public Size VideoSize { get; set; }
|
||||
public TimeSpan Duration;
|
||||
@@ -108,7 +107,7 @@ namespace mpvnet
|
||||
public float AutofitSmaller { get; set; } = 0.3f;
|
||||
public float AutofitLarger { get; set; } = 0.8f;
|
||||
|
||||
public void Init()
|
||||
public void Init(IntPtr handle)
|
||||
{
|
||||
ApplyShowMenuFix();
|
||||
|
||||
@@ -117,6 +116,8 @@ namespace mpvnet
|
||||
if (Handle == IntPtr.Zero)
|
||||
throw new Exception("error mpv_create");
|
||||
|
||||
SetPropertyLong("wid", handle.ToInt64());
|
||||
|
||||
mpv_request_log_messages(Handle, "terminal-default");
|
||||
|
||||
App.RunTask(() => EventLoop());
|
||||
@@ -127,21 +128,20 @@ namespace mpvnet
|
||||
SetPropertyString("input-terminal", "yes");
|
||||
SetPropertyString("msg-level", "osd/libass=fatal");
|
||||
}
|
||||
|
||||
SetPropertyString("watch-later-options", "mute");
|
||||
SetPropertyString("screenshot-directory", "~~desktop/");
|
||||
SetPropertyString("osd-playing-msg", "${filename}");
|
||||
SetPropertyString("wid", MainForm.Hwnd.ToString());
|
||||
SetPropertyString("osc", "yes");
|
||||
SetPropertyString("force-window", "yes");
|
||||
SetPropertyString("config-dir", ConfigFolder);
|
||||
SetPropertyString("config", "yes");
|
||||
|
||||
|
||||
SetPropertyInt("osd-duration", 2000);
|
||||
|
||||
SetPropertyBool("input-default-bindings", true);
|
||||
SetPropertyBool("input-builtin-bindings", false);
|
||||
|
||||
SetPropertyString("watch-later-options", "mute");
|
||||
SetPropertyString("screenshot-directory", "~~desktop/");
|
||||
SetPropertyString("osd-playing-msg", "${filename}");
|
||||
SetPropertyString("osc", "yes");
|
||||
SetPropertyString("force-window", "yes");
|
||||
SetPropertyString("config-dir", ConfigFolder);
|
||||
SetPropertyString("config", "yes");
|
||||
|
||||
ProcessCommandLine(true);
|
||||
mpv_error err = mpv_initialize(Handle);
|
||||
|
||||
@@ -388,9 +388,6 @@ namespace mpvnet
|
||||
IntPtr ptr = mpv_wait_event(Handle, -1);
|
||||
mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event));
|
||||
|
||||
if (WindowHandle == IntPtr.Zero)
|
||||
WindowHandle = Native.FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null);
|
||||
|
||||
try
|
||||
{
|
||||
switch (evt.event_id)
|
||||
@@ -761,6 +758,14 @@ namespace mpvnet
|
||||
HandleError(err, throwException, $"error setting property: {name} = {value}");
|
||||
}
|
||||
|
||||
public void SetPropertyLong(string name, long value, bool throwException = false)
|
||||
{
|
||||
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref value);
|
||||
|
||||
if (err < 0)
|
||||
HandleError(err, throwException, $"error setting property: {name} = {value}");
|
||||
}
|
||||
|
||||
public long GetPropertyLong(string name, bool throwException = false)
|
||||
{
|
||||
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
||||
@@ -772,15 +777,6 @@ namespace mpvnet
|
||||
return lpBuffer.ToInt64();
|
||||
}
|
||||
|
||||
public void SetPropertyLong(string name, long value, bool throwException = false)
|
||||
{
|
||||
long val = value;
|
||||
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val);
|
||||
|
||||
if (err < 0)
|
||||
HandleError(err, throwException, $"error setting property: {name} = {value}");
|
||||
}
|
||||
|
||||
public double GetPropertyDouble(string name, bool throwException = false)
|
||||
{
|
||||
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace mpvnet
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
public ElementHost CommandPaletteHost { get; set; }
|
||||
public IntPtr mpvWindowHandle { get; set; }
|
||||
public static MainForm Instance { get; set; }
|
||||
public static IntPtr Hwnd { get; set; }
|
||||
|
||||
|
||||
new WpfControls.ContextMenu ContextMenu { get; set; }
|
||||
AutoResetEvent MenuAutoResetEvent { get; } = new AutoResetEvent(false);
|
||||
Point LastCursorPosition;
|
||||
@@ -44,8 +44,7 @@ namespace mpvnet
|
||||
try
|
||||
{
|
||||
Instance = this;
|
||||
Hwnd = Handle;
|
||||
Core.Init();
|
||||
Core.Init(Handle);
|
||||
|
||||
Core.Shutdown += Core_Shutdown;
|
||||
Core.ShowMenu += Core_ShowMenu;
|
||||
@@ -812,8 +811,11 @@ namespace mpvnet
|
||||
case 0x20b: // WM_XBUTTONDOWN
|
||||
case 0x20c: // WM_XBUTTONUP
|
||||
case 0x20e: // WM_MOUSEHWHEEL
|
||||
if (Core.WindowHandle != IntPtr.Zero)
|
||||
m.Result = SendMessage(Core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
if (mpvWindowHandle == IntPtr.Zero)
|
||||
mpvWindowHandle = FindWindowEx(Handle, IntPtr.Zero, "mpv", null);
|
||||
|
||||
if (mpvWindowHandle != IntPtr.Zero)
|
||||
m.Result = SendMessage(mpvWindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x051: // WM_INPUTLANGCHANGE
|
||||
ActivateKeyboardLayout(m.LParam, 0x00000100u /*KLF_SETFORPROCESS*/);
|
||||
|
||||
Reference in New Issue
Block a user