Improved handling of default options.

This commit is contained in:
stax76
2021-10-10 15:20:12 +02:00
parent 1a475f9fe8
commit 2a3738f79e
7 changed files with 52 additions and 64 deletions

View File

@@ -3,7 +3,7 @@
- Window size flicker issue fix when changing files. - Window size flicker issue fix when changing files.
- Support input-builtin-bindings to make mp.add_key_binding behave same as in mpv. - 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) 5.5.0.3 Beta (2021-09-23)

View File

@@ -253,8 +253,10 @@ namespace mpvnet
using (var d = new OpenFileDialog()) using (var d = new OpenFileDialog())
{ {
string path = Core.GetPropertyString("path"); string path = Core.GetPropertyString("path");
if (File.Exists(path)) if (File.Exists(path))
d.InitialDirectory = Path.GetDirectoryName(path); d.InitialDirectory = Path.GetDirectoryName(path);
d.Multiselect = true; d.Multiselect = true;
if (d.ShowDialog() == DialogResult.OK) if (d.ShowDialog() == DialogResult.OK)

View File

@@ -1,6 +1,7 @@
 
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
@@ -137,18 +138,50 @@ namespace mpvnet
SetPropertyString("msg-level", "osd/libass=fatal"); 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("wid", MainForm.Hwnd.ToString());
SetPropertyString("osc", "yes"); SetPropertyString("osc", "yes");
SetPropertyString("force-window", "yes"); SetPropertyString("force-window", "yes");
SetPropertyString("config-dir", ConfigFolder); SetPropertyString("config-dir", ConfigFolder);
SetPropertyString("config", "yes"); 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); ProcessCommandLine(true);
mpv_error err = mpv_initialize(Handle); mpv_error err = mpv_initialize(Handle);
if (err < 0) if (err < 0)
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR); 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 => { ObservePropertyInt("video-rotate", value => {
VideoRotate = value; VideoRotate = value;
UpdateVideoSize("dwidth", "dheight"); UpdateVideoSize("dwidth", "dheight");
@@ -223,12 +256,6 @@ namespace mpvnet
if (!File.Exists(_ConfigFolder + "input.conf")) if (!File.Exists(_ConfigFolder + "input.conf"))
File.WriteAllText(_ConfigFolder + "input.conf", Properties.Resources.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; return _ConfigFolder;

View File

@@ -19,7 +19,7 @@ namespace mpvnet.Properties {
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // 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.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { 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: ///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 = no always use software decoding
///option = auto enable best hw decoder (see below) ///option = auto enable best hw decoder
///option = yes [rest of string was truncated]&quot;;. ///option = yes exact [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string editor_conf { internal static string editor_conf {
get { get {
@@ -82,20 +82,19 @@ namespace mpvnet.Properties {
/// <summary> /// <summary>
/// Looks up a localized string similar to /// Looks up a localized string similar to
/// # This file defines the key and mouse bindings and the context menu of mpv.net. ///# This file defines the key and mouse bindings and also the context menu of mpv.net.
/// ///
/// # A input and config editor can be found in the context menu under &apos;Settings&apos;. ///# A input and config editor can be found in the context menu under &apos;Settings&apos;.
/// ///
/// # The mpv.conf defaults of mpv.net contain: &apos;input-default-bindings = no&apos; ///# The mpv.conf defaults of mpv.net contain input-default-bindings=yes and
/// # which disables the input defaults of mpv. ///# input-builtin-bindings=no which disables the input defaults of mpv.
/// ///
/// # Every line in this file begins with a space character to make search easier, ///# The input test mode can be started via command line: --input-test
/// # if you want to know if &apos;o&apos; has already a binding you can search for &apos; o &apos;.
/// ///
/// # input test mode: ///# The input key list can be printed with --input-keylist or
/// # mpvnet --input-test ///# shown from the context menu under: View &gt; Show Keys
/// ///
/// # The [rest of string was truncated]&quot;;. ///# m [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string input_conf { internal static string input_conf {
get { get {
@@ -103,28 +102,6 @@ namespace mpvnet.Properties {
} }
} }
/// <summary>
/// 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 = &apos;${filename}&apos;
///script-opts = osc-scalewindowed=1.5,osc-hidetimeout=2000,console-scale=1
///screenshot-directory = &apos;~~desktop/&apos;
///
///[protocol.https]
///osd-playing-msg = &apos;${media-title}&apos;
///.
/// </summary>
internal static string mpv_conf {
get {
return ResourceManager.GetString("mpv_conf", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
@@ -153,12 +130,11 @@ namespace mpvnet.Properties {
///foreground = #DDDDDD ///foreground = #DDDDDD
///foreground2 = #AAAAAA ///foreground2 = #AAAAAA
///background = #323232 ///background = #323232
///highlight = #404040
/// ///
///menu-foreground = #DDDDDD ///menu-foreground = #DDDDDD
///menu-background = #323232 ///menu-background = #323232
///menu-highlight = #505050 ///menu-highlight = #505050
///menu-border = #FFFFFF
///menu-checked = #5A5A5A
/// ///
/// ///
///[light] ///[light]
@@ -167,12 +143,11 @@ namespace mpvnet.Properties {
///foreground = #000000 ///foreground = #000000
///foreground2 = #4C4C4C ///foreground2 = #4C4C4C
///background = #F7F7F7 ///background = #F7F7F7
///highlight = #DFDFDF
/// ///
///menu-foreground = #000000 ///menu-foreground = #000000
///menu-background = #DFDFDF ///menu-background = #DFDFDF
///menu-highlight = #BFBFBF ///menu-highlight = #BFBFBF
///menu-border = #6A6A6A
///menu-checked = #AAAAAA
///. ///.
/// </summary> /// </summary>
internal static string theme { internal static string theme {

View File

@@ -130,9 +130,6 @@
<data name="mpvnet_santa" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="mpvnet_santa" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mpvnet-santa.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\mpvnet-santa.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="mpv_conf" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mpv.conf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="theme" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="theme" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\theme.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> <value>..\Resources\theme.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data> </data>

View File

@@ -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

View File

@@ -231,7 +231,6 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Content Include="mpvnet.ico" /> <Content Include="mpvnet.ico" />
<Content Include="Resources\mpv.conf.txt" />
<None Include="Resources\mpvnet.ico" /> <None Include="Resources\mpvnet.ico" />
<None Include="Resources\mpvnet.png" /> <None Include="Resources\mpvnet.png" />
</ItemGroup> </ItemGroup>