From c508761c3680a05be8315f1213556a34c7b6e4ee Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Mon, 18 Mar 2019 22:00:08 +0100 Subject: [PATCH] - --- README.md | 4 + mpv.net/MainForm.cs | 25 ++- mpv.net/Properties/AssemblyInfo.cs | 4 +- mpv.net/Properties/Resources.Designer.cs | 168 ++++++++++-------- mpv.net/Properties/Resources.resx | 5 +- .../{input_conf.txt => input.conf.txt} | 3 +- mpv.net/Resources/mpv.conf.txt | 11 ++ mpv.net/mp.cs | 18 +- mpv.net/mpv.net.csproj | 15 +- release.ps1 | 1 - 10 files changed, 147 insertions(+), 107 deletions(-) rename mpv.net/Resources/{input_conf.txt => input.conf.txt} (98%) create mode 100644 mpv.net/Resources/mpv.conf.txt diff --git a/README.md b/README.md index 61cc5c5..59d96ad 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,10 @@ mp.register_event("seek", seek) # or use: mp.Seek += seek ### Changes +### 1.2 + +- a thread synchonisation bug which caused the shutdown to be delayed or frozen was fixed, it also caused the Shutdown event not to fire which caused the rating plugin not to work + ### 1.1 - added support for Python scripting via IronPython diff --git a/mpv.net/MainForm.cs b/mpv.net/MainForm.cs index ba8f45d..963cedc 100644 --- a/mpv.net/MainForm.cs +++ b/mpv.net/MainForm.cs @@ -31,10 +31,6 @@ namespace mpvnet Instance = this; Hwnd = Handle; ChangeFullscreen((mp.mpvConv.ContainsKey("fullscreen") && mp.mpvConv["fullscreen"] == "yes") || (mp.mpvConv.ContainsKey("fs") && mp.mpvConv["fs"] == "yes")); - CMS = new ContextMenuStripEx(components); - CMS.Opened += CMS_Opened; - ContextMenuStrip = CMS; - BuildMenu(); } catch (Exception ex) { @@ -44,14 +40,6 @@ namespace mpvnet public void BuildMenu() { - if (!File.Exists(mp.InputConfPath)) - { - if (!Directory.Exists(mp.mpvConfFolderPath)) - Directory.CreateDirectory(mp.mpvConfFolderPath); - - File.WriteAllText(mp.InputConfPath, Properties.Resources.input_conf); - } - foreach (var i in File.ReadAllText(mp.InputConfPath).SplitLinesNoEmpty()) { if (!i.Contains("#menu:")) @@ -129,7 +117,7 @@ namespace mpvnet private void mp_Shutdown() { if (!IsClosed) - Invoke(new Action(() => Close())); + BeginInvoke(new Action(() => Close())); } public bool IsFullscreen @@ -293,6 +281,15 @@ namespace mpvnet mp.PlaybackRestart += mp_PlaybackRestart; } + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + CMS = new ContextMenuStripEx(components); + CMS.Opened += CMS_Opened; + ContextMenuStrip = CMS; + BuildMenu(); + } + protected override void OnFormClosed(FormClosedEventArgs e) { base.OnFormClosed(e); @@ -302,7 +299,7 @@ namespace mpvnet for (int i = 0; i < 99; i++) { if (mp.IsShutdownComplete) break; - Thread.Sleep(50); + Thread.Sleep(100); } } } diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index 641fc7b..a7f8ed8 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -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("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/mpv.net/Properties/Resources.Designer.cs b/mpv.net/Properties/Resources.Designer.cs index d959c73..a491330 100644 --- a/mpv.net/Properties/Resources.Designer.cs +++ b/mpv.net/Properties/Resources.Designer.cs @@ -1,71 +1,97 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace mpvnet.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // 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", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mpvnet.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// - internal static string input_conf { - get { - return ResourceManager.GetString("input_conf", resourceCulture); - } - } - } -} \ No newline at end of file +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace mpvnet.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // 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.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mpvnet.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to # mpv.net key bindings, mouse bindings and context menu configuration + /// + /// o script-message mpv.net open-files #menu: O ; Open Files... + /// _ ignore #menu: _ ; - + /// Space cycle pause #menu: Space, Enter ; Play/Pause + /// Enter cycle pause + /// s stop #menu: S ; Stop + /// _ ignore #menu: _ ; - + /// f cycle fullscreen #menu: F ; Toggle Fullscreen /// [rest of string was truncated]";. + /// + internal static string input_conf { + get { + return ResourceManager.GetString("input_conf", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to input-ar-delay = 500 + ///input-ar-rate = 20 + ///volume = 50 + ///hwdec = yes + ///vo = direct3d + ///keep-open = yes + ///keep-open-pause = no + ///osd-playing-msg = '${filename}' + ///screenshot-directory = ~~desktop/. + /// + internal static string mpv_conf { + get { + return ResourceManager.GetString("mpv_conf", resourceCulture); + } + } + } +} diff --git a/mpv.net/Properties/Resources.resx b/mpv.net/Properties/Resources.resx index 39981e4..a8b5430 100644 --- a/mpv.net/Properties/Resources.resx +++ b/mpv.net/Properties/Resources.resx @@ -119,6 +119,9 @@ - ..\Resources\input_conf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + ..\Resources\input.conf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + + ..\Resources\mpv.conf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 \ No newline at end of file diff --git a/mpv.net/Resources/input_conf.txt b/mpv.net/Resources/input.conf.txt similarity index 98% rename from mpv.net/Resources/input_conf.txt rename to mpv.net/Resources/input.conf.txt index daa8ac6..a57342e 100644 --- a/mpv.net/Resources/input_conf.txt +++ b/mpv.net/Resources/input.conf.txt @@ -38,7 +38,7 @@ w add panscan -0.1 #menu: W ; Pan && Scan > Decrease Height W add panscan +0.1 #menu: Shift+W ; Pan && Scan > Increase Height _ ignore #menu: _ ; Pan && Scan > - - Shift+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 #menu: Alt+Backspace ; Pan && Scan > Reset + Shift+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 #menu: Shift+Backspace ; Pan && Scan > Reset Ctrl+1 add contrast -1 #menu: Ctrl+1 ; Video > Decrease Contrast Ctrl+2 add contrast 1 #menu: Ctrl+2 ; Video > Increase Contrast @@ -74,7 +74,6 @@ _ ignore #menu: _ ; Subtitle > - _ add sub-scale -0.1 #menu: _ ; Subtitle > Decrease Subtitle Font Size _ add sub-scale +0.1 #menu: _ ; Subtitle > Increase Subtitle Font Size - _ ignore #menu: _ ; Subtitle > - + add volume 10 #menu: + ; Volume > Up - add volume -10 #menu: - ; Volume > Down diff --git a/mpv.net/Resources/mpv.conf.txt b/mpv.net/Resources/mpv.conf.txt new file mode 100644 index 0000000..8d6a337 --- /dev/null +++ b/mpv.net/Resources/mpv.conf.txt @@ -0,0 +1,11 @@ +# https://mpv.io/manual/master/ + +input-ar-delay = 500 +input-ar-rate = 20 +volume = 50 +hwdec = yes +vo = direct3d +keep-open = yes +keep-open-pause = no +osd-playing-msg = ${filename} +screenshot-directory = ~~desktop/ \ No newline at end of file diff --git a/mpv.net/mp.cs b/mpv.net/mp.cs index 6643157..41f0e6b 100644 --- a/mpv.net/mp.cs +++ b/mpv.net/mp.cs @@ -88,18 +88,18 @@ namespace mpvnet public static void Init() { + if (!Directory.Exists(mp.mpvConfFolderPath)) + Directory.CreateDirectory(mp.mpvConfFolderPath); + + if (!File.Exists(mp.mpvConfPath)) + File.WriteAllText(mp.mpvConfPath, Properties.Resources.mpv_conf); + + if (!File.Exists(mp.InputConfPath)) + File.WriteAllText(mp.InputConfPath, Properties.Resources.input_conf); + LoadLibrary("mpv-1.dll"); MpvHandle = mpv_create(); - SetIntProp("input-ar-delay", 500); - SetIntProp("input-ar-rate", 20); - SetIntProp("volume", 50); - SetStringProp("hwdec", "yes"); - SetStringProp("vo", "direct3d"); SetStringProp("input-default-bindings", "yes"); - SetStringProp("osd-playing-msg", "'${filename}'"); - SetStringProp("screenshot-directory", "~~desktop/"); - SetStringProp("keep-open", "yes"); - SetStringProp("keep-open-pause", "no"); SetStringProp("osc", "yes"); SetStringProp("config", "yes"); SetStringProp("wid", MainForm.Hwnd.ToString()); diff --git a/mpv.net/mpv.net.csproj b/mpv.net/mpv.net.csproj index e9a8ea1..49a169b 100644 --- a/mpv.net/mpv.net.csproj +++ b/mpv.net/mpv.net.csproj @@ -132,6 +132,11 @@ Component + + True + True + Resources.resx + @@ -155,14 +160,9 @@ ResXFileCodeGenerator - Resources.Designer.cs Designer + Resources.Designer.cs - - True - Resources.resx - True - SettingsSingleFileGenerator @@ -173,6 +173,7 @@ Settings.settings True + @@ -180,7 +181,7 @@ - + diff --git a/release.ps1 b/release.ps1 index 7550191..214c701 100644 --- a/release.ps1 +++ b/release.ps1 @@ -4,7 +4,6 @@ $version = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath).FileVersion $desktopDir = [Environment]::GetFolderPath("Desktop") $targetDir = $desktopDir + "\mpv.net-" + $version Copy-Item $scriptDir\mpv.net\bin\Debug $targetDir -recurse -$addonDir = $targetDir + "\Addons" $7zPath = "C:\Program Files\7-Zip\7z.exe" $args = "a -t7z -mx9 $targetDir.7z -r $targetDir\*" Start-Process -FilePath $7zPath -ArgumentList $args \ No newline at end of file