Skip to content

Commit 2f73521

Browse files
committed
v7.1.1.0
1 parent 23ed145 commit 2f73521

File tree

6 files changed

+116
-102
lines changed

6 files changed

+116
-102
lines changed

docs/changelog.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11

2-
# v7.1.0.1 Beta (2024-??-??)
2+
# v7.1.1.0 (2024-02-03)
33

44
- Chinese and Japanese translation updated. Thanks to the translation team!
5+
- Fix command line arguments being ingnored in some situations.
56

67

7-
# v7.1.0.0 Beta (2024-01-12)
8+
# v7.1.0.0 (2024-01-12)
89

910
- The menu item that shows profiles was moved into the menu item that lists profiles.
1011
- Fix geometry not working when used from mpv.conf and the conf editor.

src/MpvNet.Windows/MpvNet.Windows.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<UseWindowsForms>true</UseWindowsForms>
1212
<ApplicationIcon>mpv-icon.ico</ApplicationIcon>
1313
<Product>mpv.net</Product>
14-
<FileVersion>7.1.0.0</FileVersion>
15-
<AssemblyVersion>7.1.0.0</AssemblyVersion>
16-
<InformationalVersion>7.1.0.0</InformationalVersion>
14+
<FileVersion>7.1.1.0</FileVersion>
15+
<AssemblyVersion>7.1.1.0</AssemblyVersion>
16+
<InformationalVersion>7.1.1.0</InformationalVersion>
1717
<Nullable>enable</Nullable>
1818
</PropertyGroup>
1919

src/MpvNet.Windows/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ static void Main()
101101
else if (App.CommandLine.Contains("--o="))
102102
{
103103
App.AutoLoadFolder = false;
104-
Player.Init(IntPtr.Zero);
105-
Player.ProcessCommandLineArgsPost();
106-
Player.ProcessCommandLineFiles();
104+
Player.Init(IntPtr.Zero, true);
105+
CommandLine.ProcessCommandLineArgsPostInit();
106+
CommandLine.ProcessCommandLineFiles();
107107
Player.SetPropertyString("idle", "no");
108108
Player.EventLoop();
109109
Player.Destroy();

src/MpvNet.Windows/WinForms/MainForm.cs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,30 @@ public MainForm()
6868
GuiCommand.Current.WindowScaleNet += GuiCommand_WindowScaleNet;
6969
GuiCommand.Current.ShowMenu += GuiCommand_ShowMenu;
7070

71-
Init();
71+
Player.Init(Handle, true);
72+
73+
// bool methods not working correctly
74+
Player.ObserveProperty("window-maximized", PropChangeWindowMaximized);
75+
Player.ObserveProperty("window-minimized", PropChangeWindowMinimized);
76+
77+
Player.ObservePropertyBool("border", PropChangeBorder);
78+
Player.ObservePropertyBool("fullscreen", PropChangeFullscreen);
79+
Player.ObservePropertyBool("keepaspect-window", value => Player.KeepaspectWindow = value);
80+
Player.ObservePropertyBool("ontop", PropChangeOnTop);
81+
Player.ObservePropertyBool("title-bar", PropChangeTitleBar);
82+
83+
Player.ObservePropertyString("sid", PropChangeSid);
84+
Player.ObservePropertyString("aid", PropChangeAid);
85+
Player.ObservePropertyString("vid", PropChangeVid);
86+
87+
Player.ObservePropertyString("title", PropChangeTitle);
88+
89+
Player.ObservePropertyInt("edition", PropChangeEdition);
90+
91+
Player.ObservePropertyDouble("window-scale", PropChangeWindowScale);
92+
93+
CommandLine.ProcessCommandLineArgsPostInit();
94+
CommandLine.ProcessCommandLineFiles();
7295

7396
_taskbarButtonCreatedMessage = RegisterWindowMessage("TaskbarButtonCreated");
7497

@@ -145,34 +168,6 @@ void Player_PlaylistPosChanged(int pos)
145168
SetTitle();
146169
}
147170

148-
void Init()
149-
{
150-
Player.Init(Handle);
151-
152-
// bool methods not working correctly
153-
Player.ObserveProperty("window-maximized", PropChangeWindowMaximized);
154-
Player.ObserveProperty("window-minimized", PropChangeWindowMinimized);
155-
156-
Player.ObservePropertyBool("border", PropChangeBorder);
157-
Player.ObservePropertyBool("fullscreen", PropChangeFullscreen);
158-
Player.ObservePropertyBool("keepaspect-window", value => Player.KeepaspectWindow = value);
159-
Player.ObservePropertyBool("ontop", PropChangeOnTop);
160-
Player.ObservePropertyBool("title-bar", PropChangeTitleBar);
161-
162-
Player.ObservePropertyString("sid", PropChangeSid);
163-
Player.ObservePropertyString("aid", PropChangeAid);
164-
Player.ObservePropertyString("vid", PropChangeVid);
165-
166-
Player.ObservePropertyString("title", PropChangeTitle);
167-
168-
Player.ObservePropertyInt("edition", PropChangeEdition);
169-
170-
Player.ObservePropertyDouble("window-scale", PropChangeWindowScale);
171-
172-
Player.ProcessCommandLineArgsPost();
173-
Player.ProcessCommandLineFiles();
174-
}
175-
176171
void PropChangeWindowScale(double scale)
177172
{
178173
if (!WasShown)

src/MpvNet/CommandLine.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ public class CommandLine
55
{
66
static List<StringPair>? _arguments;
77

8+
static string[] _preInitProperties { get; } = {
9+
"input-terminal", "terminal", "input-file", "config", "o",
10+
"config-dir", "input-conf", "load-scripts", "scripts", "player-operation-mode",
11+
"idle", "log-file", "msg-color", "dump-stats", "msg-level", "really-quiet" };
12+
813
public static List<StringPair> Arguments
914
{
1015
get
@@ -53,6 +58,78 @@ public static List<StringPair> Arguments
5358
}
5459
}
5560

61+
public static void ProcessCommandLineArgsPreInit()
62+
{
63+
foreach (var pair in Arguments)
64+
{
65+
if (pair.Name.EndsWith("-add") ||
66+
pair.Name.EndsWith("-set") ||
67+
pair.Name.EndsWith("-pre") ||
68+
pair.Name.EndsWith("-clr") ||
69+
pair.Name.EndsWith("-append") ||
70+
pair.Name.EndsWith("-remove") ||
71+
pair.Name.EndsWith("-toggle"))
72+
{
73+
continue;
74+
}
75+
76+
Player.ProcessProperty(pair.Name, pair.Value);
77+
78+
if (!App.ProcessProperty(pair.Name, pair.Value))
79+
Player.SetPropertyString(pair.Name, pair.Value);
80+
}
81+
}
82+
83+
public static void ProcessCommandLineArgsPostInit()
84+
{
85+
foreach (var pair in Arguments)
86+
{
87+
if (_preInitProperties.Contains(pair.Name))
88+
continue;
89+
90+
if (pair.Name.EndsWith("-add"))
91+
Player.CommandV("change-list", pair.Name[..^4], "add", pair.Value);
92+
else if (pair.Name.EndsWith("-set"))
93+
Player.CommandV("change-list", pair.Name[..^4], "set", pair.Value);
94+
else if (pair.Name.EndsWith("-append"))
95+
Player.CommandV("change-list", pair.Name[..^7], "append", pair.Value);
96+
else if (pair.Name.EndsWith("-pre"))
97+
Player.CommandV("change-list", pair.Name[..^4], "pre", pair.Value);
98+
else if (pair.Name.EndsWith("-clr"))
99+
Player.CommandV("change-list", pair.Name[..^4], "clr", "");
100+
else if (pair.Name.EndsWith("-remove"))
101+
Player.CommandV("change-list", pair.Name[..^7], "remove", pair.Value);
102+
else if (pair.Name.EndsWith("-toggle"))
103+
Player.CommandV("change-list", pair.Name[..^7], "toggle", pair.Value);
104+
else
105+
{
106+
Player.ProcessProperty(pair.Name, pair.Value);
107+
108+
if (!App.ProcessProperty(pair.Name, pair.Value))
109+
Player.SetPropertyString(pair.Name, pair.Value);
110+
}
111+
}
112+
}
113+
114+
public static void ProcessCommandLineFiles()
115+
{
116+
List<string> files = new List<string>();
117+
118+
foreach (string arg in Environment.GetCommandLineArgs().Skip(1))
119+
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") ||
120+
arg.Contains(":\\") || arg.StartsWith("\\\\") || File.Exists(arg)))
121+
122+
files.Add(arg);
123+
124+
Player.LoadFiles(files.ToArray(), !App.Queue, App.Queue);
125+
126+
if (App.CommandLine.Contains("--shuffle"))
127+
{
128+
Player.Command("playlist-shuffle");
129+
Player.SetPropertyInt("playlist-pos", 0);
130+
}
131+
}
132+
56133
public static bool Contains(string name)
57134
{
58135
foreach (StringPair pair in Arguments)

src/MpvNet/Player.cs

Lines changed: 6 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class MainPlayer : MpvClient
6666
public event Action<int>? PlaylistPosChanged;
6767
public event Action<Size>? VideoSizeChanged;
6868

69-
public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
69+
public void Init(IntPtr formHandle, bool processCommandLine)
7070
{
7171
App.ApplyShowMenuFix();
7272

@@ -93,7 +93,10 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
9393
}
9494

9595
if (formHandle != IntPtr.Zero)
96+
{
97+
SetPropertyString("force-window", "yes");
9698
SetPropertyLong("wid", formHandle.ToInt64());
99+
}
97100

98101
SetPropertyInt("osd-duration", 2000);
99102

@@ -104,7 +107,6 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
104107
SetPropertyString("screenshot-directory", "~~desktop/");
105108
SetPropertyString("osd-playing-msg", "${media-title}");
106109
SetPropertyString("osc", "yes");
107-
SetPropertyString("force-window", "yes");
108110
SetPropertyString("config-dir", ConfigFolder);
109111
SetPropertyString("config", "yes");
110112

@@ -113,8 +115,8 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
113115
if (!string.IsNullOrEmpty(UsedInputConfContent))
114116
SetPropertyString("input-conf", @"memory://" + UsedInputConfContent);
115117

116-
if (processCommandLineArguments)
117-
ProcessCommandLineArgs();
118+
if (processCommandLine)
119+
CommandLine.ProcessCommandLineArgsPreInit();
118120

119121
if (CommandLine.Contains("config-dir"))
120122
{
@@ -415,67 +417,6 @@ void ProcessBluRayLogMessage(string msg)
415417

416418
public void SetBluRayTitle(int id) => LoadFiles(new[] { @"bd://" + id }, false, false);
417419

418-
public void ProcessCommandLineArgs()
419-
{
420-
foreach (var pair in CommandLine.Arguments)
421-
{
422-
if (pair.Name.EndsWith("-add") ||
423-
pair.Name.EndsWith("-set") ||
424-
pair.Name.EndsWith("-pre") ||
425-
pair.Name.EndsWith("-clr") ||
426-
pair.Name.EndsWith("-append") ||
427-
pair.Name.EndsWith("-remove") ||
428-
pair.Name.EndsWith("-toggle"))
429-
430-
continue;
431-
432-
ProcessProperty(pair.Name, pair.Value);
433-
434-
if (!App.ProcessProperty(pair.Name, pair.Value))
435-
SetPropertyString(pair.Name, pair.Value);
436-
}
437-
}
438-
439-
public void ProcessCommandLineArgsPost()
440-
{
441-
foreach (var pair in CommandLine.Arguments)
442-
{
443-
if (pair.Name.EndsWith("-add"))
444-
CommandV("change-list", pair.Name[..^4], "add", pair.Value);
445-
else if (pair.Name.EndsWith("-set"))
446-
CommandV("change-list", pair.Name[..^4], "set", pair.Value);
447-
else if (pair.Name.EndsWith("-append"))
448-
CommandV("change-list", pair.Name[..^7], "append", pair.Value);
449-
else if (pair.Name.EndsWith("-pre"))
450-
CommandV("change-list", pair.Name[..^4], "pre", pair.Value);
451-
else if (pair.Name.EndsWith("-clr"))
452-
CommandV("change-list", pair.Name[..^4], "clr", "");
453-
else if (pair.Name.EndsWith("-remove"))
454-
CommandV("change-list", pair.Name[..^7], "remove", pair.Value);
455-
else if (pair.Name.EndsWith("-toggle"))
456-
CommandV("change-list", pair.Name[..^7], "toggle", pair.Value);
457-
}
458-
}
459-
460-
public void ProcessCommandLineFiles()
461-
{
462-
List<string> files = new List<string>();
463-
464-
foreach (string arg in Environment.GetCommandLineArgs().Skip(1))
465-
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") ||
466-
arg.Contains(":\\") || arg.StartsWith("\\\\") || File.Exists(arg)))
467-
468-
files.Add(arg);
469-
470-
LoadFiles(files.ToArray(), !App.Queue, App.Queue);
471-
472-
if (App.CommandLine.Contains("--shuffle"))
473-
{
474-
Command("playlist-shuffle");
475-
SetPropertyInt("playlist-pos", 0);
476-
}
477-
}
478-
479420
public DateTime LastLoad;
480421

481422
public void LoadFiles(string[]? files, bool loadFolder, bool append)

0 commit comments

Comments
 (0)