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 single-instance not working with unicode filenames
- bug fix for logo not shown - bug fix for logo not shown on start
- bug fix osd-visibility.js script causing memory leak - 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 ### 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 // 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("5.1.0.0")] [assembly: AssemblyVersion("5.1.0.1")]
[assembly: AssemblyFileVersion("5.1.0.0")] [assembly: AssemblyFileVersion("5.1.0.1")]

View File

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

View File

@@ -1,4 +1,5 @@
using System.Windows; using System.IO;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
@@ -9,7 +10,8 @@ namespace mpvnet
public AboutWindow() public AboutWindow()
{ {
InitializeComponent(); 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(); protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();

View File

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

View File

@@ -98,6 +98,7 @@ namespace mpvnet
if (App.IsStartedFromTerminal) if (App.IsStartedFromTerminal)
{ {
set_property_string("terminal", "yes"); set_property_string("terminal", "yes");
set_property_string("input-terminal", "yes");
set_property_string("msg-level", "osd/libass=fatal"); set_property_string("msg-level", "osd/libass=fatal");
} }
@@ -108,10 +109,11 @@ namespace mpvnet
set_property_string("config-dir", ConfigFolder); set_property_string("config-dir", ConfigFolder);
set_property_string("config", "yes"); set_property_string("config", "yes");
ProcessCommandLine(true);
mpv_initialize(Handle); mpv_initialize(Handle);
Initialized?.Invoke(); Initialized?.Invoke();
LoadMpvScripts(); LoadMpvScripts();
if (GPUAPI != "vulkan") ProcessCommandLine(); if (GPUAPI != "vulkan") ProcessCommandLine(false);
} }
public static void ProcessProperty(string name, string value) public static void ProcessProperty(string name, string value)
@@ -564,40 +566,40 @@ namespace mpvnet
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action)); 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); var args = Environment.GetCommandLineArgs().Skip(1);
List<string> files = new List<string>();
//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) foreach (string i in args)
{ {
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") || File.Exists(i))) string arg = i;
{
files.Add(i);
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
}
}
foreach (string i in args) if (arg.StartsWith("--"))
{
if (i.StartsWith("--"))
{ {
try try
{ {
if (i.Contains("=")) 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))
{ {
string left = i.Substring(2, i.IndexOf("=") - 2);
string right = i.Substring(left.Length + 3);
mp.ProcessProperty(left, right); mp.ProcessProperty(left, right);
if (!App.ProcessProperty(left, right)) if (!App.ProcessProperty(left, right))
set_property_string(left, right, true); set_property_string(left, right, true);
} }
else else if (!preInit && !preInitProperties.Contains(left))
{ {
string name = i.Substring(2); mp.ProcessProperty(left, right);
mp.ProcessProperty(name, "yes"); if (!App.ProcessProperty(left, right))
if (!App.ProcessProperty(name, "yes")) set_property_string(left, right, true);
set_property_string(name, "yes", true);
} }
} }
catch (Exception e) catch (Exception e)
@@ -607,12 +609,26 @@ namespace mpvnet
} }
} }
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control)); if (!preInit)
if (files.Count == 0 || files[0].Contains("://"))
{ {
VideoSizeAutoResetEvent.Set(); List<string> files = new List<string>();
VideoSizeChanged?.Invoke();
foreach (string i in args)
{
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") || File.Exists(i)))
{
files.Add(i);
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
}
}
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
if (files.Count == 0 || files[0].Contains("://"))
{
VideoSizeAutoResetEvent.Set();
VideoSizeChanged?.Invoke();
}
} }
} }