From 2a3738f79e5379d3dc323f5bf0e439b1da34a346 Mon Sep 17 00:00:00 2001 From: stax76 Date: Sun, 10 Oct 2021 15:20:12 +0200 Subject: [PATCH] Improved handling of default options. --- docs/Changelog.md | 2 +- src/Misc/Commands.cs | 2 + src/Misc/CorePlayer.cs | 39 ++++++++++++++++--- src/Properties/Resources.Designer.cs | 57 ++++++++-------------------- src/Properties/Resources.resx | 3 -- src/Resources/mpv.conf.txt | 12 ------ src/mpv.net.csproj | 1 - 7 files changed, 52 insertions(+), 64 deletions(-) delete mode 100644 src/Resources/mpv.conf.txt diff --git a/docs/Changelog.md b/docs/Changelog.md index 2a4c159..2ee4d93 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -3,7 +3,7 @@ - Window size flicker issue fix when changing files. - Support input-builtin-bindings to make mp.add_key_binding behave same as in mpv. -- libmpv avih 2021-10-08 +- libmpv shinchiro 2021-10-10 5.5.0.3 Beta (2021-09-23) diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index eb7fccf..98de9c7 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -253,8 +253,10 @@ namespace mpvnet using (var d = new OpenFileDialog()) { string path = Core.GetPropertyString("path"); + if (File.Exists(path)) d.InitialDirectory = Path.GetDirectoryName(path); + d.Multiselect = true; if (d.ShowDialog() == DialogResult.OK) diff --git a/src/Misc/CorePlayer.cs b/src/Misc/CorePlayer.cs index 7b1f779..7b0c32c 100644 --- a/src/Misc/CorePlayer.cs +++ b/src/Misc/CorePlayer.cs @@ -1,6 +1,7 @@  using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; @@ -137,18 +138,50 @@ namespace mpvnet SetPropertyString("msg-level", "osd/libass=fatal"); } + SetPropertyString("watch-later-options", "mute"); + SetPropertyString("screenshot-directory", "~~desktop/"); + SetPropertyString("script-opts", "osc-scalewindowed=1.5,osc-hidetimeout=2000,console-scale=1.5"); + SetPropertyString("osd-playing-msg", "${filename}"); SetPropertyString("wid", MainForm.Hwnd.ToString()); SetPropertyString("osc", "yes"); SetPropertyString("force-window", "yes"); SetPropertyString("config-dir", ConfigFolder); SetPropertyString("config", "yes"); + SetPropertyInt("input-ar-delay", 500); + SetPropertyInt("input-ar-rate", 20); + SetPropertyInt("osd-duration", 2000); + + SetPropertyBool("keep-open", true); + SetPropertyBool("keep-open-pause", false); + ProcessCommandLine(true); mpv_error err = mpv_initialize(Handle); if (err < 0) throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR); + if (Debugger.IsAttached) + { + if (GetPropertyString("property-list").Contains("input-builtin-bindings")) + { + SetPropertyBool("input-default-bindings", true); + SetPropertyBool("input-builtin-bindings", false); + } + else + SetPropertyBool("input-default-bindings", false); + } + else + { + SetPropertyBool("input-default-bindings", true); + + try { + SetPropertyBool("input-builtin-bindings", false, true); + } catch { + SetPropertyBool("input-default-bindings", false); + } + } + ObservePropertyInt("video-rotate", value => { VideoRotate = value; UpdateVideoSize("dwidth", "dheight"); @@ -223,12 +256,6 @@ namespace mpvnet if (!File.Exists(_ConfigFolder + "input.conf")) File.WriteAllText(_ConfigFolder + "input.conf", Properties.Resources.input_conf); - - if (!File.Exists(_ConfigFolder + "mpv.conf")) - { - string conf = Properties.Resources.mpv_conf; - File.WriteAllText(_ConfigFolder + "mpv.conf", conf); - } } return _ConfigFolder; diff --git a/src/Properties/Resources.Designer.cs b/src/Properties/Resources.Designer.cs index 6781eeb..f427d33 100644 --- a/src/Properties/Resources.Designer.cs +++ b/src/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace mpvnet.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -71,8 +71,8 @@ namespace mpvnet.Properties { ///help = Specify the hardware video decoding API that should be used if possible. Whether hardware decoding is actually done depends on the video codec. If hardware decoding is not possible, mpv will fall back on software decoding.\n\nFor more information visit: /// ///option = no always use software decoding - ///option = auto enable best hw decoder (see below) - ///option = yes [rest of string was truncated]";. + ///option = auto enable best hw decoder + ///option = yes exact [rest of string was truncated]";. /// internal static string editor_conf { get { @@ -82,20 +82,19 @@ namespace mpvnet.Properties { /// /// Looks up a localized string similar to - /// # This file defines the key and mouse bindings and the context menu of mpv.net. - /// - /// # A input and config editor can be found in the context menu under 'Settings'. - /// - /// # The mpv.conf defaults of mpv.net contain: 'input-default-bindings = no' - /// # which disables the input defaults of mpv. - /// - /// # Every line in this file begins with a space character to make search easier, - /// # if you want to know if 'o' has already a binding you can search for ' o '. + ///# This file defines the key and mouse bindings and also the context menu of mpv.net. /// - /// # input test mode: - /// # mpvnet --input-test + ///# A input and config editor can be found in the context menu under 'Settings'. /// - /// # The [rest of string was truncated]";. + ///# The mpv.conf defaults of mpv.net contain input-default-bindings=yes and + ///# input-builtin-bindings=no which disables the input defaults of mpv. + /// + ///# The input test mode can be started via command line: --input-test + /// + ///# The input key list can be printed with --input-keylist or + ///# shown from the context menu under: View > Show Keys + /// + ///# m [rest of string was truncated]";. /// internal static string input_conf { get { @@ -103,28 +102,6 @@ namespace mpvnet.Properties { } } - /// - /// Looks up a localized string similar to - ///input-default-bindings = no - ///input-ar-delay = 500 - ///input-ar-rate = 20 - ///keep-open = yes - ///keep-open-pause = no - ///osd-duration = 2000 - ///osd-playing-msg = '${filename}' - ///script-opts = osc-scalewindowed=1.5,osc-hidetimeout=2000,console-scale=1 - ///screenshot-directory = '~~desktop/' - /// - ///[protocol.https] - ///osd-playing-msg = '${media-title}' - ///. - /// - internal static string mpv_conf { - get { - return ResourceManager.GetString("mpv_conf", resourceCulture); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -153,12 +130,11 @@ namespace mpvnet.Properties { ///foreground = #DDDDDD ///foreground2 = #AAAAAA ///background = #323232 + ///highlight = #404040 /// ///menu-foreground = #DDDDDD ///menu-background = #323232 ///menu-highlight = #505050 - ///menu-border = #FFFFFF - ///menu-checked = #5A5A5A /// /// ///[light] @@ -167,12 +143,11 @@ namespace mpvnet.Properties { ///foreground = #000000 ///foreground2 = #4C4C4C ///background = #F7F7F7 + ///highlight = #DFDFDF /// ///menu-foreground = #000000 ///menu-background = #DFDFDF ///menu-highlight = #BFBFBF - ///menu-border = #6A6A6A - ///menu-checked = #AAAAAA ///. /// internal static string theme { diff --git a/src/Properties/Resources.resx b/src/Properties/Resources.resx index 46fa61b..0d8d15f 100644 --- a/src/Properties/Resources.resx +++ b/src/Properties/Resources.resx @@ -130,9 +130,6 @@ ..\Resources\mpvnet-santa.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\mpv.conf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - ..\Resources\theme.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 diff --git a/src/Resources/mpv.conf.txt b/src/Resources/mpv.conf.txt deleted file mode 100644 index bf21559..0000000 --- a/src/Resources/mpv.conf.txt +++ /dev/null @@ -1,12 +0,0 @@ - -input-default-bindings = yes -input-builtin-bindings = no -input-ar-delay = 500 -input-ar-rate = 20 -keep-open = yes -keep-open-pause = no -osd-duration = 2000 -osd-playing-msg = '${filename}' -script-opts = osc-scalewindowed=1.5,osc-hidetimeout=2000,console-scale=1.5 -screenshot-directory = '~~desktop/' -watch-later-options = mute diff --git a/src/mpv.net.csproj b/src/mpv.net.csproj index a8305ae..9152c94 100644 --- a/src/mpv.net.csproj +++ b/src/mpv.net.csproj @@ -231,7 +231,6 @@ True -