Merge branch 'master' of https://github.com/stax76/mpv.net
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- Load AviSynth DLL from environment variable AviSynthDLL
|
- Load AviSynth DLL from environment variable AviSynthDLL
|
||||||
in order to support AviSynth portable mode.
|
in order to support AviSynth portable mode.
|
||||||
|
- New option global-media-keys (next, previous, play/pause, stop)
|
||||||
|
|
||||||
|
|
||||||
5.4.8.4 Beta
|
5.4.8.4 Beta
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace mpvnet
|
|||||||
public static bool AutoLoadFolder { get; set; } = true;
|
public static bool AutoLoadFolder { get; set; } = true;
|
||||||
public static bool Queue { get; set; }
|
public static bool Queue { get; set; }
|
||||||
public static bool UpdateCheck { get; set; }
|
public static bool UpdateCheck { get; set; }
|
||||||
|
public static bool GlobalMediaKeys { get; set; }
|
||||||
|
|
||||||
public static int StartThreshold { get; set; } = 1500;
|
public static int StartThreshold { get; set; } = 1500;
|
||||||
public static int RecentCount { get; set; } = 15;
|
public static int RecentCount { get; set; } = 15;
|
||||||
@@ -52,7 +53,7 @@ namespace mpvnet
|
|||||||
foreach (var i in Conf)
|
foreach (var i in Conf)
|
||||||
ProcessProperty(i.Key, i.Value, true);
|
ProcessProperty(i.Key, i.Value, true);
|
||||||
|
|
||||||
if (App.DebugMode)
|
if (DebugMode)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -106,14 +107,14 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
if (obj is Exception e)
|
if (obj is Exception e)
|
||||||
{
|
{
|
||||||
if (App.IsStartedFromTerminal)
|
if (IsStartedFromTerminal)
|
||||||
ConsoleHelp.WriteError(e.ToString());
|
ConsoleHelp.WriteError(e.ToString());
|
||||||
else
|
else
|
||||||
Msg.ShowException(e);
|
Msg.ShowException(e);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (App.IsStartedFromTerminal)
|
if (IsStartedFromTerminal)
|
||||||
ConsoleHelp.WriteError(obj.ToString());
|
ConsoleHelp.WriteError(obj.ToString());
|
||||||
else
|
else
|
||||||
Msg.ShowError(obj.ToString());
|
Msg.ShowError(obj.ToString());
|
||||||
@@ -122,7 +123,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void ShowError(string title, string msg)
|
public static void ShowError(string title, string msg)
|
||||||
{
|
{
|
||||||
if (App.IsStartedFromTerminal)
|
if (IsStartedFromTerminal)
|
||||||
{
|
{
|
||||||
ConsoleHelp.WriteError(title);
|
ConsoleHelp.WriteError(title);
|
||||||
ConsoleHelp.WriteError(msg);
|
ConsoleHelp.WriteError(msg);
|
||||||
@@ -135,8 +136,8 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
if (RememberVolume)
|
if (RememberVolume)
|
||||||
{
|
{
|
||||||
core.set_property_int("volume", RegistryHelp.GetInt(App.RegPath, "Volume", 70));
|
core.set_property_int("volume", RegistryHelp.GetInt(RegPath, "Volume", 70));
|
||||||
core.set_property_string("mute", RegistryHelp.GetString(App.RegPath, "Mute", "no"));
|
core.set_property_string("mute", RegistryHelp.GetString(RegPath, "Mute", "no"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,8 +145,8 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
if (RememberVolume)
|
if (RememberVolume)
|
||||||
{
|
{
|
||||||
RegistryHelp.SetValue(App.RegPath, "Volume", core.get_property_int("volume"));
|
RegistryHelp.SetValue(RegPath, "Volume", core.get_property_int("volume"));
|
||||||
RegistryHelp.SetValue(App.RegPath, "Mute", core.get_property_string("mute"));
|
RegistryHelp.SetValue(RegPath, "Mute", core.get_property_string("mute"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +171,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
|
case "global-media-keys": GlobalMediaKeys = value == "yes"; return true;
|
||||||
case "remember-position": RememberPosition = value == "yes"; return true;
|
case "remember-position": RememberPosition = value == "yes"; return true;
|
||||||
case "debug-mode": DebugMode = value == "yes"; return true;
|
case "debug-mode": DebugMode = value == "yes"; return true;
|
||||||
case "remember-volume": RememberVolume = value == "yes"; return true;
|
case "remember-volume": RememberVolume = value == "yes"; return true;
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
public class WinAPI
|
public class WinAPI
|
||||||
{
|
{
|
||||||
|
public const int VK_MEDIA_NEXT_TRACK = 0xB0;
|
||||||
|
public const int VK_MEDIA_PREV_TRACK = 0xB1;
|
||||||
|
public const int VK_MEDIA_STOP = 0xB2;
|
||||||
|
public const int VK_MEDIA_PLAY_PAUSE = 0xB3;
|
||||||
|
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
public static extern bool AttachConsole(int dwProcessId);
|
public static extern bool AttachConsole(int dwProcessId);
|
||||||
|
|
||||||
@@ -14,8 +19,12 @@ public class WinAPI
|
|||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
public static extern IntPtr LoadLibrary(string path);
|
public static extern IntPtr LoadLibrary(string path);
|
||||||
|
|
||||||
|
[DllImport("user32")]
|
||||||
|
public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||||
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
public static extern IntPtr FindWindowEx(
|
||||||
|
IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
using static WinAPI;
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
public static class NativeHelp
|
public static class NativeHelp
|
||||||
@@ -21,19 +23,19 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SubtractWindowBorders(IntPtr hwnd, ref WinAPI.RECT rc)
|
public static void SubtractWindowBorders(IntPtr hwnd, ref RECT rc)
|
||||||
{
|
{
|
||||||
var b = new WinAPI.RECT(0, 0, 0, 0);
|
RECT r = new RECT(0, 0, 0, 0);
|
||||||
AddWindowBorders(hwnd, ref b);
|
AddWindowBorders(hwnd, ref r);
|
||||||
rc.Left -= b.Left;
|
rc.Left -= r.Left;
|
||||||
rc.Top -= b.Top;
|
rc.Top -= r.Top;
|
||||||
rc.Right -= b.Right;
|
rc.Right -= r.Right;
|
||||||
rc.Bottom -= b.Bottom;
|
rc.Bottom -= r.Bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddWindowBorders(IntPtr hwnd, ref WinAPI.RECT rc)
|
public static void AddWindowBorders(IntPtr hwnd, ref RECT rc)
|
||||||
{
|
{
|
||||||
WinAPI.AdjustWindowRect(ref rc, (uint)WinAPI.GetWindowLong(hwnd, -16 /* GWL_STYLE */), false);
|
AdjustWindowRect(ref rc, (uint)GetWindowLong(hwnd, -16 /* GWL_STYLE */), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -516,6 +516,15 @@ help = "For single files automatically load the entire directory into the playli
|
|||||||
options = [{ name = "yes" },
|
options = [{ name = "yes" },
|
||||||
{ name = "no" }]
|
{ name = "no" }]
|
||||||
|
|
||||||
|
[[settings]]
|
||||||
|
name = "global-media-keys"
|
||||||
|
file = "mpvnet"
|
||||||
|
default = "no"
|
||||||
|
filter = "Input"
|
||||||
|
help = "Enable global media keys next track, previous track, play/pause, stop. (mpv.net specific setting)"
|
||||||
|
options = [{ name = "yes" },
|
||||||
|
{ name = "no" }]
|
||||||
|
|
||||||
[[settings]]
|
[[settings]]
|
||||||
name = "input-ar-delay"
|
name = "input-ar-delay"
|
||||||
file = "mpv"
|
file = "mpv"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System.Diagnostics;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using static mpvnet.Core;
|
using static mpvnet.Core;
|
||||||
|
using static WinAPI;
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
@@ -49,6 +50,14 @@ namespace mpvnet
|
|||||||
ConsoleHelp.Padding = 60;
|
ConsoleHelp.Padding = 60;
|
||||||
core.Init();
|
core.Init();
|
||||||
|
|
||||||
|
if (App.GlobalMediaKeys)
|
||||||
|
{
|
||||||
|
RegisterGlobalKey(VK_MEDIA_NEXT_TRACK);
|
||||||
|
RegisterGlobalKey(VK_MEDIA_PREV_TRACK);
|
||||||
|
RegisterGlobalKey(VK_MEDIA_PLAY_PAUSE);
|
||||||
|
RegisterGlobalKey(VK_MEDIA_STOP);
|
||||||
|
}
|
||||||
|
|
||||||
core.Shutdown += Shutdown;
|
core.Shutdown += Shutdown;
|
||||||
core.VideoSizeChanged += VideoSizeChanged;
|
core.VideoSizeChanged += VideoSizeChanged;
|
||||||
core.FileLoaded += FileLoaded;
|
core.FileLoaded += FileLoaded;
|
||||||
@@ -76,7 +85,7 @@ namespace mpvnet
|
|||||||
Application.ThreadException += (sender, e) => App.ShowException(e.Exception);
|
Application.ThreadException += (sender, e) => App.ShowException(e.Exception);
|
||||||
Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
|
Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
|
||||||
Text = "mpv.net " + Application.ProductVersion;
|
Text = "mpv.net " + Application.ProductVersion;
|
||||||
TaskbarButtonCreatedMessage = WinAPI.RegisterWindowMessage("TaskbarButtonCreated");
|
TaskbarButtonCreatedMessage = RegisterWindowMessage("TaskbarButtonCreated");
|
||||||
|
|
||||||
ContextMenu = new ContextMenuStripEx(components);
|
ContextMenu = new ContextMenuStripEx(components);
|
||||||
ContextMenu.Opened += ContextMenu_Opened;
|
ContextMenu.Opened += ContextMenu_Opened;
|
||||||
@@ -367,7 +376,7 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
|
|
||||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
||||||
var rect = new WinAPI.RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
|
var rect = new RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
|
||||||
NativeHelp.AddWindowBorders(Handle, ref rect);
|
NativeHelp.AddWindowBorders(Handle, ref rect);
|
||||||
int left = middlePos.X - rect.Width / 2;
|
int left = middlePos.X - rect.Width / 2;
|
||||||
int top = middlePos.Y - rect.Height / 2;
|
int top = middlePos.Y - rect.Height / 2;
|
||||||
@@ -390,7 +399,7 @@ namespace mpvnet
|
|||||||
if (top + rect.Height > maxBottom)
|
if (top + rect.Height > maxBottom)
|
||||||
top = maxBottom - rect.Height;
|
top = maxBottom - rect.Height;
|
||||||
|
|
||||||
WinAPI.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */,
|
SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */,
|
||||||
left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,7 +420,7 @@ namespace mpvnet
|
|||||||
Rectangle b = Screen.FromControl(this).Bounds;
|
Rectangle b = Screen.FromControl(this).Bounds;
|
||||||
uint SWP_SHOWWINDOW = 0x0040;
|
uint SWP_SHOWWINDOW = 0x0040;
|
||||||
IntPtr HWND_TOP= IntPtr.Zero;
|
IntPtr HWND_TOP= IntPtr.Zero;
|
||||||
WinAPI.SetWindowPos(Handle, HWND_TOP, b.X, b.Y, b.Width, b.Height, SWP_SHOWWINDOW);
|
SetWindowPos(Handle, HWND_TOP, b.X, b.Y, b.Width, b.Height, SWP_SHOWWINDOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -546,7 +555,7 @@ namespace mpvnet
|
|||||||
(Environment.TickCount - LastAppCommand) < 1000;
|
(Environment.TickCount - LastAppCommand) < 1000;
|
||||||
|
|
||||||
if (core.WindowHandle != IntPtr.Zero && !skip)
|
if (core.WindowHandle != IntPtr.Zero && !skip)
|
||||||
m.Result = WinAPI.SendMessage(core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
m.Result = SendMessage(core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x319: // WM_APPCOMMAND
|
case 0x319: // WM_APPCOMMAND
|
||||||
@@ -562,6 +571,23 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 0x0312: // WM_HOTKEY
|
||||||
|
switch (m.WParam.ToInt64())
|
||||||
|
{
|
||||||
|
case VK_MEDIA_NEXT_TRACK:
|
||||||
|
core.command("keypress NEXT");
|
||||||
|
break;
|
||||||
|
case VK_MEDIA_PREV_TRACK:
|
||||||
|
core.command("keypress PREV");
|
||||||
|
break;
|
||||||
|
case VK_MEDIA_PLAY_PAUSE:
|
||||||
|
core.command("keypress PLAYPAUSE");
|
||||||
|
break;
|
||||||
|
case VK_MEDIA_STOP:
|
||||||
|
core.command("keypress STOP");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 0x0200: // WM_MOUSEMOVE
|
case 0x0200: // WM_MOUSEMOVE
|
||||||
if (Environment.TickCount - LastCycleFullscreen > 500)
|
if (Environment.TickCount - LastCycleFullscreen > 500)
|
||||||
{
|
{
|
||||||
@@ -587,13 +613,13 @@ namespace mpvnet
|
|||||||
if (!WasShown())
|
if (!WasShown())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
WinAPI.RECT rect = Marshal.PtrToStructure<WinAPI.RECT>(m.LParam);
|
RECT rect = Marshal.PtrToStructure<RECT>(m.LParam);
|
||||||
WinAPI.SetWindowPos(Handle, IntPtr.Zero, rect.Left, rect.Top, rect.Width, rect.Height, 0);
|
SetWindowPos(Handle, IntPtr.Zero, rect.Left, rect.Top, rect.Width, rect.Height, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x0214: // WM_SIZING
|
case 0x0214: // WM_SIZING
|
||||||
{
|
{
|
||||||
var rc = Marshal.PtrToStructure<WinAPI.RECT>(m.LParam);
|
var rc = Marshal.PtrToStructure<RECT>(m.LParam);
|
||||||
var r = rc;
|
var r = rc;
|
||||||
NativeHelp.SubtractWindowBorders(Handle, ref r);
|
NativeHelp.SubtractWindowBorders(Handle, ref r);
|
||||||
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
|
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
|
||||||
@@ -613,13 +639,13 @@ namespace mpvnet
|
|||||||
if (corner >= 0)
|
if (corner >= 0)
|
||||||
corners[corner] -= d_corners[corner];
|
corners[corner] -= d_corners[corner];
|
||||||
|
|
||||||
Marshal.StructureToPtr<WinAPI.RECT>(new WinAPI.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
|
Marshal.StructureToPtr<RECT>(new RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
|
||||||
m.Result = new IntPtr(1);
|
m.Result = new IntPtr(1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case 0x004A: // WM_COPYDATA
|
case 0x004A: // WM_COPYDATA
|
||||||
{
|
{
|
||||||
var copyData = (WinAPI.COPYDATASTRUCT)m.GetLParam(typeof(WinAPI.COPYDATASTRUCT));
|
var copyData = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT));
|
||||||
string[] files = copyData.lpData.Split('\n');
|
string[] files = copyData.lpData.Split('\n');
|
||||||
string mode = files[0];
|
string mode = files[0];
|
||||||
files = files.Skip(1).ToArray();
|
files = files.Skip(1).ToArray();
|
||||||
@@ -673,6 +699,8 @@ namespace mpvnet
|
|||||||
Taskbar.SetValue(core.get_property_number("time-pos"), core.Duration.TotalSeconds);
|
Taskbar.SetValue(core.get_property_number("time-pos"), core.Duration.TotalSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RegisterGlobalKey(int key) => RegisterHotKey(Handle, key, 0, (uint)key);
|
||||||
|
|
||||||
void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
|
void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
|
||||||
|
|
||||||
void PropChangeAid(string value) => core.Aid = value;
|
void PropChangeAid(string value) => core.Aid = value;
|
||||||
@@ -792,7 +820,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
base.OnActivated(e);
|
base.OnActivated(e);
|
||||||
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
|
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
|
||||||
WinAPI.SendMessage(MainForm.Instance.Handle, m.Msg, m.WParam, m.LParam);
|
SendMessage(MainForm.Instance.Handle, m.Msg, m.WParam, m.LParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnResize(EventArgs e)
|
protected override void OnResize(EventArgs e)
|
||||||
@@ -849,8 +877,8 @@ namespace mpvnet
|
|||||||
e.Button == MouseButtons.Left && !IsMouseInOSC())
|
e.Button == MouseButtons.Left && !IsMouseInOSC())
|
||||||
{
|
{
|
||||||
var HTCAPTION = new IntPtr(2);
|
var HTCAPTION = new IntPtr(2);
|
||||||
WinAPI.ReleaseCapture();
|
ReleaseCapture();
|
||||||
WinAPI.PostMessage(Handle, 0xA1 /* WM_NCLBUTTONDOWN */, HTCAPTION, IntPtr.Zero);
|
PostMessage(Handle, 0xA1 /* WM_NCLBUTTONDOWN */, HTCAPTION, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Width - e.Location.X < 10 && e.Location.Y < 10)
|
if (Width - e.Location.X < 10 && e.Location.Y < 10)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
using static libmpv;
|
using static libmpv;
|
||||||
using static NewLine;
|
using static NewLine;
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
|
|||||||
Reference in New Issue
Block a user