command line processing was improved

This commit is contained in:
Frank Skare
2019-08-05 03:06:40 +02:00
parent 3f74344b99
commit ad30dc5ae2
7 changed files with 59 additions and 33 deletions

View File

@@ -1,8 +1,15 @@
###
- bug fix for single-instance not working with unicode filenames
- bug fix for logo not shown
- bug fix osd-visibility.js script causing memory leak
- bug fix for logo not shown on start
- osd-visibility.js script was removed because the OSC uses too much memory
- youtube-dl was updated
- in case mpv.net is started from a terminal it sets now the mpv property input-terminal to yes,
this means mpv.net will now receive input keys from the terminal
- command line processing was improved, certain properties didn't work, now they should work:
(input-terminal, terminal, input-file, config, config-dir, input-conf,
load-scripts, script, scripts, player-operation-mode)
- the about dialog shows now the mpv version and build date
### 5.1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.1.0.0")]
[assembly: AssemblyFileVersion("5.1.0.0")]
[assembly: AssemblyVersion("5.1.0.1")]
[assembly: AssemblyFileVersion("5.1.0.1")]

View File

@@ -4,13 +4,14 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="About mpv.net" Height="230" Width="420" FontSize="16" ShowInTaskbar="False"
Title="About mpv.net" Height="230" Width="500" FontSize="16" ShowInTaskbar="False"
WindowStartupLocation="CenterOwner" ResizeMode="NoResize">
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock FontSize="48" HorizontalAlignment="Center" Margin="0,0,0,10">mpv.net</TextBlock>
<TextBlock HorizontalAlignment="Center">Copyright (c) 2017-2019 Frank Skare (stax76)</TextBlock>
<TextBlock Name="Version" HorizontalAlignment="Center" />
<TextBlock Name="mpvVersion" HorizontalAlignment="Center" />
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,20">MIT License</TextBlock>
</StackPanel>
</Grid>

View File

@@ -1,4 +1,5 @@
using System.Windows;
using System.IO;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
@@ -9,7 +10,8 @@ namespace mpvnet
public AboutWindow()
{
InitializeComponent();
Version.Text = $"Version {System.Windows.Forms.Application.ProductVersion}";
Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion}";
mpvVersion.Text = $"{mp.get_property_string("mpv-version")} ({File.GetLastWriteTime(PathHelp.StartupPath + "mpv-1.dll").ToShortDateString()})";
}
protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();

View File

@@ -511,7 +511,7 @@ namespace mpvnet
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (mp.GPUAPI == "vulkan") mp.ProcessCommandLine();
if (mp.GPUAPI == "vulkan") mp.ProcessCommandLine(false);
var wpfColor = WPF.WPF.ThemeColor;
Color color = Color.FromArgb(wpfColor.A, wpfColor.R, wpfColor.G, wpfColor.B);
ToolStripRendererEx.InitColors(color, App.IsDarkMode, App.ThemedMenu);

View File

@@ -98,6 +98,7 @@ namespace mpvnet
if (App.IsStartedFromTerminal)
{
set_property_string("terminal", "yes");
set_property_string("input-terminal", "yes");
set_property_string("msg-level", "osd/libass=fatal");
}
@@ -108,10 +109,11 @@ namespace mpvnet
set_property_string("config-dir", ConfigFolder);
set_property_string("config", "yes");
ProcessCommandLine(true);
mpv_initialize(Handle);
Initialized?.Invoke();
LoadMpvScripts();
if (GPUAPI != "vulkan") ProcessCommandLine();
if (GPUAPI != "vulkan") ProcessCommandLine(false);
}
public static void ProcessProperty(string name, string value)
@@ -564,9 +566,51 @@ namespace mpvnet
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action));
}
public static void ProcessCommandLine()
public static void ProcessCommandLine(bool preInit)
{
var args = Environment.GetCommandLineArgs().Skip(1);
//Msg.Show(string.Join("\n", args));
string[] preInitProperties = { "input-terminal", "terminal", "input-file", "config", "config-dir", "input-conf", "load-scripts", "scripts", "player-operation-mode" };
foreach (string i in args)
{
string arg = i;
if (arg.StartsWith("--"))
{
try
{
if (!arg.Contains("=")) arg += "=yes";
string left = arg.Substring(2, arg.IndexOf("=") - 2);
string right = arg.Substring(left.Length + 3);
if (left == "script") left = "scripts";
if (preInit && preInitProperties.Contains(left))
{
mp.ProcessProperty(left, right);
if (!App.ProcessProperty(left, right))
set_property_string(left, right, true);
}
else if (!preInit && !preInitProperties.Contains(left))
{
mp.ProcessProperty(left, right);
if (!App.ProcessProperty(left, right))
set_property_string(left, right, true);
}
}
catch (Exception e)
{
Msg.ShowException(e);
}
}
}
if (!preInit)
{
List<string> files = new List<string>();
foreach (string i in args)
@@ -578,35 +622,6 @@ namespace mpvnet
}
}
foreach (string i in args)
{
if (i.StartsWith("--"))
{
try
{
if (i.Contains("="))
{
string left = i.Substring(2, i.IndexOf("=") - 2);
string right = i.Substring(left.Length + 3);
mp.ProcessProperty(left, right);
if (!App.ProcessProperty(left, right))
set_property_string(left, right, true);
}
else
{
string name = i.Substring(2);
mp.ProcessProperty(name, "yes");
if (!App.ProcessProperty(name, "yes"))
set_property_string(name, "yes", true);
}
}
catch (Exception e)
{
Msg.ShowException(e);
}
}
}
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
if (files.Count == 0 || files[0].Contains("://"))
@@ -615,6 +630,7 @@ namespace mpvnet
VideoSizeChanged?.Invoke();
}
}
}
public static DateTime LastLoad;