diff --git a/docs/changelog.md b/docs/changelog.md
index 6df9b3bc..c037b273 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -1,10 +1,11 @@
-# v7.1.0.1 Beta (2024-??-??)
+# v7.1.1.0 (2024-02-03)
- Chinese and Japanese translation updated. Thanks to the translation team!
+- Fix command line arguments being ingnored in some situations.
-# v7.1.0.0 Beta (2024-01-12)
+# v7.1.0.0 (2024-01-12)
- The menu item that shows profiles was moved into the menu item that lists profiles.
- Fix geometry not working when used from mpv.conf and the conf editor.
diff --git a/src/MpvNet.Windows/MpvNet.Windows.csproj b/src/MpvNet.Windows/MpvNet.Windows.csproj
index 5fbe2bec..b8ddcf36 100644
--- a/src/MpvNet.Windows/MpvNet.Windows.csproj
+++ b/src/MpvNet.Windows/MpvNet.Windows.csproj
@@ -11,9 +11,9 @@
true
mpv-icon.ico
mpv.net
- 7.1.0.0
- 7.1.0.0
- 7.1.0.0
+ 7.1.1.0
+ 7.1.1.0
+ 7.1.1.0
enable
diff --git a/src/MpvNet.Windows/Program.cs b/src/MpvNet.Windows/Program.cs
index 6558cf78..57e6141b 100644
--- a/src/MpvNet.Windows/Program.cs
+++ b/src/MpvNet.Windows/Program.cs
@@ -101,9 +101,9 @@ static void Main()
else if (App.CommandLine.Contains("--o="))
{
App.AutoLoadFolder = false;
- Player.Init(IntPtr.Zero);
- Player.ProcessCommandLineArgsPost();
- Player.ProcessCommandLineFiles();
+ Player.Init(IntPtr.Zero, true);
+ CommandLine.ProcessCommandLineArgsPostInit();
+ CommandLine.ProcessCommandLineFiles();
Player.SetPropertyString("idle", "no");
Player.EventLoop();
Player.Destroy();
diff --git a/src/MpvNet.Windows/WinForms/MainForm.cs b/src/MpvNet.Windows/WinForms/MainForm.cs
index fdfa64cc..64553865 100644
--- a/src/MpvNet.Windows/WinForms/MainForm.cs
+++ b/src/MpvNet.Windows/WinForms/MainForm.cs
@@ -68,7 +68,30 @@ public MainForm()
GuiCommand.Current.WindowScaleNet += GuiCommand_WindowScaleNet;
GuiCommand.Current.ShowMenu += GuiCommand_ShowMenu;
- Init();
+ Player.Init(Handle, true);
+
+ // bool methods not working correctly
+ Player.ObserveProperty("window-maximized", PropChangeWindowMaximized);
+ Player.ObserveProperty("window-minimized", PropChangeWindowMinimized);
+
+ Player.ObservePropertyBool("border", PropChangeBorder);
+ Player.ObservePropertyBool("fullscreen", PropChangeFullscreen);
+ Player.ObservePropertyBool("keepaspect-window", value => Player.KeepaspectWindow = value);
+ Player.ObservePropertyBool("ontop", PropChangeOnTop);
+ Player.ObservePropertyBool("title-bar", PropChangeTitleBar);
+
+ Player.ObservePropertyString("sid", PropChangeSid);
+ Player.ObservePropertyString("aid", PropChangeAid);
+ Player.ObservePropertyString("vid", PropChangeVid);
+
+ Player.ObservePropertyString("title", PropChangeTitle);
+
+ Player.ObservePropertyInt("edition", PropChangeEdition);
+
+ Player.ObservePropertyDouble("window-scale", PropChangeWindowScale);
+
+ CommandLine.ProcessCommandLineArgsPostInit();
+ CommandLine.ProcessCommandLineFiles();
_taskbarButtonCreatedMessage = RegisterWindowMessage("TaskbarButtonCreated");
@@ -145,34 +168,6 @@ void Player_PlaylistPosChanged(int pos)
SetTitle();
}
- void Init()
- {
- Player.Init(Handle);
-
- // bool methods not working correctly
- Player.ObserveProperty("window-maximized", PropChangeWindowMaximized);
- Player.ObserveProperty("window-minimized", PropChangeWindowMinimized);
-
- Player.ObservePropertyBool("border", PropChangeBorder);
- Player.ObservePropertyBool("fullscreen", PropChangeFullscreen);
- Player.ObservePropertyBool("keepaspect-window", value => Player.KeepaspectWindow = value);
- Player.ObservePropertyBool("ontop", PropChangeOnTop);
- Player.ObservePropertyBool("title-bar", PropChangeTitleBar);
-
- Player.ObservePropertyString("sid", PropChangeSid);
- Player.ObservePropertyString("aid", PropChangeAid);
- Player.ObservePropertyString("vid", PropChangeVid);
-
- Player.ObservePropertyString("title", PropChangeTitle);
-
- Player.ObservePropertyInt("edition", PropChangeEdition);
-
- Player.ObservePropertyDouble("window-scale", PropChangeWindowScale);
-
- Player.ProcessCommandLineArgsPost();
- Player.ProcessCommandLineFiles();
- }
-
void PropChangeWindowScale(double scale)
{
if (!WasShown)
diff --git a/src/MpvNet/CommandLine.cs b/src/MpvNet/CommandLine.cs
index 72bbd9b1..5364b4d0 100644
--- a/src/MpvNet/CommandLine.cs
+++ b/src/MpvNet/CommandLine.cs
@@ -5,6 +5,11 @@ public class CommandLine
{
static List? _arguments;
+ static string[] _preInitProperties { get; } = {
+ "input-terminal", "terminal", "input-file", "config", "o",
+ "config-dir", "input-conf", "load-scripts", "scripts", "player-operation-mode",
+ "idle", "log-file", "msg-color", "dump-stats", "msg-level", "really-quiet" };
+
public static List Arguments
{
get
@@ -53,6 +58,78 @@ public static List Arguments
}
}
+ public static void ProcessCommandLineArgsPreInit()
+ {
+ foreach (var pair in Arguments)
+ {
+ if (pair.Name.EndsWith("-add") ||
+ pair.Name.EndsWith("-set") ||
+ pair.Name.EndsWith("-pre") ||
+ pair.Name.EndsWith("-clr") ||
+ pair.Name.EndsWith("-append") ||
+ pair.Name.EndsWith("-remove") ||
+ pair.Name.EndsWith("-toggle"))
+ {
+ continue;
+ }
+
+ Player.ProcessProperty(pair.Name, pair.Value);
+
+ if (!App.ProcessProperty(pair.Name, pair.Value))
+ Player.SetPropertyString(pair.Name, pair.Value);
+ }
+ }
+
+ public static void ProcessCommandLineArgsPostInit()
+ {
+ foreach (var pair in Arguments)
+ {
+ if (_preInitProperties.Contains(pair.Name))
+ continue;
+
+ if (pair.Name.EndsWith("-add"))
+ Player.CommandV("change-list", pair.Name[..^4], "add", pair.Value);
+ else if (pair.Name.EndsWith("-set"))
+ Player.CommandV("change-list", pair.Name[..^4], "set", pair.Value);
+ else if (pair.Name.EndsWith("-append"))
+ Player.CommandV("change-list", pair.Name[..^7], "append", pair.Value);
+ else if (pair.Name.EndsWith("-pre"))
+ Player.CommandV("change-list", pair.Name[..^4], "pre", pair.Value);
+ else if (pair.Name.EndsWith("-clr"))
+ Player.CommandV("change-list", pair.Name[..^4], "clr", "");
+ else if (pair.Name.EndsWith("-remove"))
+ Player.CommandV("change-list", pair.Name[..^7], "remove", pair.Value);
+ else if (pair.Name.EndsWith("-toggle"))
+ Player.CommandV("change-list", pair.Name[..^7], "toggle", pair.Value);
+ else
+ {
+ Player.ProcessProperty(pair.Name, pair.Value);
+
+ if (!App.ProcessProperty(pair.Name, pair.Value))
+ Player.SetPropertyString(pair.Name, pair.Value);
+ }
+ }
+ }
+
+ public static void ProcessCommandLineFiles()
+ {
+ List files = new List();
+
+ foreach (string arg in Environment.GetCommandLineArgs().Skip(1))
+ if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") ||
+ arg.Contains(":\\") || arg.StartsWith("\\\\") || File.Exists(arg)))
+
+ files.Add(arg);
+
+ Player.LoadFiles(files.ToArray(), !App.Queue, App.Queue);
+
+ if (App.CommandLine.Contains("--shuffle"))
+ {
+ Player.Command("playlist-shuffle");
+ Player.SetPropertyInt("playlist-pos", 0);
+ }
+ }
+
public static bool Contains(string name)
{
foreach (StringPair pair in Arguments)
diff --git a/src/MpvNet/Player.cs b/src/MpvNet/Player.cs
index c943f705..817bc540 100644
--- a/src/MpvNet/Player.cs
+++ b/src/MpvNet/Player.cs
@@ -66,7 +66,7 @@ public class MainPlayer : MpvClient
public event Action? PlaylistPosChanged;
public event Action? VideoSizeChanged;
- public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
+ public void Init(IntPtr formHandle, bool processCommandLine)
{
App.ApplyShowMenuFix();
@@ -93,7 +93,10 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
}
if (formHandle != IntPtr.Zero)
+ {
+ SetPropertyString("force-window", "yes");
SetPropertyLong("wid", formHandle.ToInt64());
+ }
SetPropertyInt("osd-duration", 2000);
@@ -104,7 +107,6 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
SetPropertyString("screenshot-directory", "~~desktop/");
SetPropertyString("osd-playing-msg", "${media-title}");
SetPropertyString("osc", "yes");
- SetPropertyString("force-window", "yes");
SetPropertyString("config-dir", ConfigFolder);
SetPropertyString("config", "yes");
@@ -113,8 +115,8 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
if (!string.IsNullOrEmpty(UsedInputConfContent))
SetPropertyString("input-conf", @"memory://" + UsedInputConfContent);
- if (processCommandLineArguments)
- ProcessCommandLineArgs();
+ if (processCommandLine)
+ CommandLine.ProcessCommandLineArgsPreInit();
if (CommandLine.Contains("config-dir"))
{
@@ -415,67 +417,6 @@ void ProcessBluRayLogMessage(string msg)
public void SetBluRayTitle(int id) => LoadFiles(new[] { @"bd://" + id }, false, false);
- public void ProcessCommandLineArgs()
- {
- foreach (var pair in CommandLine.Arguments)
- {
- if (pair.Name.EndsWith("-add") ||
- pair.Name.EndsWith("-set") ||
- pair.Name.EndsWith("-pre") ||
- pair.Name.EndsWith("-clr") ||
- pair.Name.EndsWith("-append") ||
- pair.Name.EndsWith("-remove") ||
- pair.Name.EndsWith("-toggle"))
-
- continue;
-
- ProcessProperty(pair.Name, pair.Value);
-
- if (!App.ProcessProperty(pair.Name, pair.Value))
- SetPropertyString(pair.Name, pair.Value);
- }
- }
-
- public void ProcessCommandLineArgsPost()
- {
- foreach (var pair in CommandLine.Arguments)
- {
- if (pair.Name.EndsWith("-add"))
- CommandV("change-list", pair.Name[..^4], "add", pair.Value);
- else if (pair.Name.EndsWith("-set"))
- CommandV("change-list", pair.Name[..^4], "set", pair.Value);
- else if (pair.Name.EndsWith("-append"))
- CommandV("change-list", pair.Name[..^7], "append", pair.Value);
- else if (pair.Name.EndsWith("-pre"))
- CommandV("change-list", pair.Name[..^4], "pre", pair.Value);
- else if (pair.Name.EndsWith("-clr"))
- CommandV("change-list", pair.Name[..^4], "clr", "");
- else if (pair.Name.EndsWith("-remove"))
- CommandV("change-list", pair.Name[..^7], "remove", pair.Value);
- else if (pair.Name.EndsWith("-toggle"))
- CommandV("change-list", pair.Name[..^7], "toggle", pair.Value);
- }
- }
-
- public void ProcessCommandLineFiles()
- {
- List files = new List();
-
- foreach (string arg in Environment.GetCommandLineArgs().Skip(1))
- if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") ||
- arg.Contains(":\\") || arg.StartsWith("\\\\") || File.Exists(arg)))
-
- files.Add(arg);
-
- LoadFiles(files.ToArray(), !App.Queue, App.Queue);
-
- if (App.CommandLine.Contains("--shuffle"))
- {
- Command("playlist-shuffle");
- SetPropertyInt("playlist-pos", 0);
- }
- }
-
public DateTime LastLoad;
public void LoadFiles(string[]? files, bool loadFolder, bool append)