Compare commits

...

7 Commits
4.2 ... 4.3.1

Author SHA1 Message Date
Frank Skare
e5c9df31e4 - 2019-06-22 06:27:22 +02:00
Frank Skare
c0a8e895f7 - 2019-06-19 18:22:40 +02:00
Frank Skare
064ae44ecf - 2019-06-19 18:03:14 +02:00
Frank Skare
005ba6e5ea - 2019-06-18 16:20:02 +02:00
Frank Skare
9f6aba6cbd - 2019-06-18 16:08:28 +02:00
Frank Skare
87e3d9ca3e - 2019-06-17 21:35:14 +02:00
Frank Skare
29a0eae3d5 - 2019-06-16 12:46:04 +02:00
9 changed files with 97 additions and 70 deletions

View File

@@ -1,9 +1,17 @@
### 4.2 Letting Go ### 4.3.1
- there was a old bug setting the screen property
### 4.3
- there was new bug in file association feature
### 4.2
- the help and layout in the config editor was improved - the help and layout in the config editor was improved
- clipboard monitoring for URLs can be disabled in the settings - clipboard monitoring for URLs can be disabled in the settings
- the context menu has a new feature: Open > Add files to playlist, - the context menu has a new feature: Open > Add files to playlist,
it appends files to the playlist [(Default binding)](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L34) it appends files to the playlist [(Default binding)](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L33)
- a setting was added to force using a single mpv.net process instance - a setting was added to force using a single mpv.net process instance
### 4.1 ### 4.1

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -12,6 +13,7 @@ using System.Runtime.Serialization;
using System.Windows.Forms; using System.Windows.Forms;
using Microsoft.Win32; using Microsoft.Win32;
using VB = Microsoft.VisualBasic;
namespace mpvnet namespace mpvnet
{ {
@@ -28,6 +30,8 @@ namespace mpvnet
public static string DarkMode { get; set; } = "always"; public static string DarkMode { get; set; } = "always";
public static string ProcessInstance { get; set; } = "single"; public static string ProcessInstance { get; set; } = "single";
public static bool DebugMode { get; set; } = false;
public static bool IsDarkMode { public static bool IsDarkMode {
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always"; get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
} }
@@ -36,6 +40,28 @@ namespace mpvnet
{ {
foreach (var i in Conf) foreach (var i in Conf)
ProcessProperty(i.Key, i.Value); ProcessProperty(i.Key, i.Value);
if (App.DebugMode)
{
try
{
string filePath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\mpvnet-debug.log";
if (File.Exists(filePath)) File.Delete(filePath);
Trace.Listeners.Clear();
Trace.Listeners.Add(new TextWriterTraceListener(filePath));
foreach (Screen screen in Screen.AllScreens)
Trace.WriteLine(screen);
}
catch (Exception e)
{
Msg.ShowException(e);
}
}
}
public static void Exit()
{
if (Trace.Listeners.Count > 0) Trace.Listeners[0].Close();
} }
static Dictionary<string, string> _Conf; static Dictionary<string, string> _Conf;
@@ -62,6 +88,7 @@ namespace mpvnet
case "clipboard-monitoring": ClipboardMonitoring = value; break; case "clipboard-monitoring": ClipboardMonitoring = value; break;
case "process-instance": ProcessInstance = value; break; case "process-instance": ProcessInstance = value; break;
case "dark-mode": DarkMode = value; break; case "dark-mode": DarkMode = value; break;
case "debug-mode": DebugMode = value == "yes"; break;
} }
} }
@@ -212,14 +239,18 @@ namespace mpvnet
public static void RemoveKey(string path) public static void RemoveKey(string path)
{ {
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false); try {
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
} catch { }
} }
public static void RemoveValue(string path, string name) public static void RemoveValue(string path, string name)
{ {
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true)) try {
if (!(rk is null)) using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true))
rk.DeleteValue(name, false); if (!(rk is null))
rk.DeleteValue(name, false);
} catch {}
} }
static RegistryKey GetRootKey(string path) static RegistryKey GetRootKey(string path)

View File

@@ -13,8 +13,6 @@ namespace mpvnet
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst);
try try
{ {
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray(); string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
@@ -28,6 +26,7 @@ namespace mpvnet
} }
App.Init(); App.Init();
Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst);
if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst) if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst)
{ {
@@ -50,21 +49,19 @@ namespace mpvnet
} catch {} } catch {}
} }
mutex.Dispose();
return; return;
} }
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm()); Application.Run(new MainForm());
mutex.Dispose();
} }
catch (Exception ex) catch (Exception ex)
{ {
Msg.ShowException(ex); Msg.ShowException(ex);
} }
finally
{
mutex.Dispose();
}
} }
} }
} }

View File

@@ -27,6 +27,9 @@ namespace mpvnet
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
[DllImport("user32.dll")]
public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
[DllImport("user32.dll", EntryPoint = "GetWindowLong")] [DllImport("user32.dll", EntryPoint = "GetWindowLong")]
private static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex); private static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.2.0.0")] [assembly: AssemblyVersion("4.3.1.0")]
[assembly: AssemblyFileVersion("4.2.0.0")] [assembly: AssemblyFileVersion("4.3.1.0")]

View File

@@ -214,7 +214,7 @@ help = "See sub-color. Color used for sub text background. You can use sub-shado
name = "screen" name = "screen"
default = "" default = ""
filter = "Screen" filter = "Screen"
help = "In multi-monitor configurations (i.e. a single desktop that spans across multiple displays), this option tells mpv which screen to display the video on." help = "<0-32> In multi-monitor configurations (i.e. a single desktop that spans across multiple displays), this option tells mpv which screen to display the video on."
[[settings]] [[settings]]
name = "osd-playing-msg" name = "osd-playing-msg"

View File

@@ -22,4 +22,12 @@ filter = "mpv.net"
help = "Defines if more then one mpv.net process is allowed." help = "Defines if more then one mpv.net process is allowed."
options = [{ name = "multi", help = "Create a new process everytime the shell starts mpv.net" }, options = [{ name = "multi", help = "Create a new process everytime the shell starts mpv.net" },
{ name = "single", help = "Force a single process everytime the shell starts mpv.net" }, { name = "single", help = "Force a single process everytime the shell starts mpv.net" },
{ name = "queue", help = "Force a single process and add files to playlist" }] { name = "queue", help = "Force a single process and add files to playlist" }]
[[settings]]
name = "debug-mode"
default = "no"
filter = "mpv.net"
help = "Writes debug info to a file located on the desktop."
options = [{ name = "yes" },
{ name = "no" }]

View File

@@ -49,10 +49,8 @@ namespace mpvnet
var dummy = mp.Conf; var dummy = mp.Conf;
App.ProcessCommandLineEarly(); App.ProcessCommandLineEarly();
if (mp.Screen == -1) mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen); if (mp.Screen == -1) mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
SetScreen(mp.Screen); SetScreen(mp.Screen);
ChangeFullscreen(mp.Fullscreen); ChangeFullscreen(mp.Fullscreen);
} }
catch (Exception ex) catch (Exception ex)
@@ -224,9 +222,6 @@ namespace mpvnet
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;
Screen[] screens = Screen.AllScreens; Screen[] screens = Screen.AllScreens;
if (left < screens[0].Bounds.Left) left = screens[0].Bounds.Left;
int maxLeft = screens[0].Bounds.Left + screens.Select((sc) => sc.Bounds.Width).Sum() - rect.Width - SystemInformation.CaptionHeight;
if (left > maxLeft) left = maxLeft;
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */); Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
} }
@@ -343,13 +338,17 @@ namespace mpvnet
if (mp.WindowHandle != IntPtr.Zero) if (mp.WindowHandle != IntPtr.Zero)
Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam); Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
break; break;
case 0x0200: // WM_MOUSEMOVE
Point pos = PointToClient(Cursor.Position);
mp.command_string($"mouse {pos.X} {pos.Y}");
if (CursorHelp.IsPosDifferent(LastCursorPosChanged)) CursorHelp.Show();
break;
case 0x319: // WM_APPCOMMAND case 0x319: // WM_APPCOMMAND
if (mp.WindowHandle != IntPtr.Zero) if (mp.WindowHandle != IntPtr.Zero)
Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam); Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
break; break;
case 0x203: // Native.WM.LBUTTONDBLCLK case 0x203: // Native.WM.LBUTTONDBLCLK
if (!IsMouseInOSC()) if (!IsMouseInOSC()) mp.command_string("cycle fullscreen");
mp.command_string("cycle fullscreen");
break; break;
case 0x02E0: // WM_DPICHANGED case 0x02E0: // WM_DPICHANGED
if (IgnoreDpiChanged) break; if (IgnoreDpiChanged) break;
@@ -389,8 +388,7 @@ namespace mpvnet
break; break;
case "queue": case "queue":
foreach (string file in files) foreach (string file in files)
if (File.Exists(file)) mp.commandv("loadfile", file, "append");
mp.commandv("loadfile", file, "append");
break; break;
} }
} }
@@ -436,15 +434,6 @@ namespace mpvnet
mp.commandv("quit"); mp.commandv("quit");
} }
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
mp.command_string($"mouse {e.X} {e.Y}");
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
CursorHelp.Show();
}
bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9; bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
void Timer_Tick(object sender, EventArgs e) void Timer_Tick(object sender, EventArgs e)
@@ -511,6 +500,7 @@ namespace mpvnet
{ {
base.OnFormClosed(e); base.OnFormClosed(e);
RegistryHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray()); RegistryHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray());
App.Exit();
mp.commandv("quit"); mp.commandv("quit");
mp.AutoResetEvent.WaitOne(3000); mp.AutoResetEvent.WaitOne(3000);
} }

View File

@@ -193,7 +193,10 @@ namespace mpvnet
mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event)); mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event));
if (WindowHandle == IntPtr.Zero) if (WindowHandle == IntPtr.Zero)
{
WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null);
//Native.EnableWindow(WindowHandle, true);
}
//Debug.WriteLine(evt.event_id.ToString()); //Debug.WriteLine(evt.event_id.ToString());
@@ -561,47 +564,34 @@ namespace mpvnet
{ {
if (files is null || files.Length == 0) return; if (files is null || files.Length == 0) return;
HideLogo(); HideLogo();
List<string> fileList = files.ToList();
foreach (string file in files) { for (int i = 0; i < files.Length; i++)
string ext = Path.GetExtension(file).TrimStart('.').ToLower(); if (App.SubtitleTypes.Contains(Path.GetExtension(files[i]).TrimStart('.').ToLower()))
if (App.SubtitleTypes.Contains(ext)) { mp.commandv("sub-add", files[i]);
mp.commandv("sub-add", file); else
fileList.Remove(file); if (i == 0)
} mp.commandv("loadfile", files[i]);
} else
mp.commandv("loadfile", files[i], "append");
if (fileList.Count == 0) return; Task.Run(() => LoadFolder()); // user reported race condition
files = fileList.ToArray();
int count = mp.get_property_int("playlist-count");
foreach (string file in files)
mp.commandv("loadfile", file, "append");
mp.set_property_int("playlist-pos", count);
for (int i = 0; i < count; i++)
mp.commandv("playlist-remove", "0");
mp.LoadFolder(files[0]);
} }
static void LoadFolder(string path) static void LoadFolder()
{ {
if (get_property_int("playlist-count") == 1) Thread.Sleep(50); // user reported race condition
{ string path = mp.get_property_string("path");
if (!File.Exists(path)) return; if (!File.Exists(path) || get_property_int("playlist-count") != 1) return;
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList(); List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
files = files.Where((file) => App.VideoTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower()) || files = files.Where((file) =>
App.AudioTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower())).ToList(); App.VideoTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower()) ||
files.Sort(new StringLogicalComparer()); App.AudioTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower())).ToList();
int index = files.IndexOf(path); files.Sort(new StringLogicalComparer());
files.Remove(path); int index = files.IndexOf(path);
foreach (string i in files) files.Remove(path);
commandv("loadfile", i, "append"); foreach (string i in files)
if (index > 0) commandv("loadfile", i, "append");
commandv("playlist-move", "0", (index + 1).ToString()); if (index > 0) commandv("playlist-move", "0", (index + 1).ToString());
}
} }
static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers) static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers)