From 8899f4b77225153e409c95855a6dd2e73599f04b Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Thu, 27 Jun 2019 06:59:34 +0200 Subject: [PATCH] - --- Changelog.md | 3 +++ addons/RatingAddon/RatingAddon.cs | 5 +---- mpv.net/Properties/AssemblyInfo.cs | 2 +- mpv.net/Resources/mpvNetConfToml.txt | 2 +- mpv.net/mpv/mp.cs | 32 ++++++++++++++-------------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Changelog.md b/Changelog.md index 37b8249..bb56725 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,9 @@ ### - opening a URL manually no longer uses a input box but uses the clipboard directly +- the manifest was missing the company attribute which caused + mpv.net not appearing in the 'Open with' menu of the Windows File Explorer, + thanks to 44vince44 for pointing this out!!! ### 4.4 diff --git a/addons/RatingAddon/RatingAddon.cs b/addons/RatingAddon/RatingAddon.cs index bd4042b..31766ae 100644 --- a/addons/RatingAddon/RatingAddon.cs +++ b/addons/RatingAddon/RatingAddon.cs @@ -46,11 +46,8 @@ namespace RatingAddon void ClientMessage(string[] args) { - if (args == null || args.Length != 2 || args[0] != "rate-file" || - ! int.TryParse(args[1], out int rating)) - + if (args.Length != 2 || args[0] != "rate-file" || ! int.TryParse(args[1], out int rating)) return; - Dic[mp.get_property_string("path")] = rating; mp.commandv("show-text", $"Rating: {rating}"); } diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index 862b5f0..ded9d0b 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("mpv.net")] [assembly: AssemblyDescription("A modern media player")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] +[assembly: AssemblyCompany("Frank Skare (stax76)")] [assembly: AssemblyProduct("mpv.net")] [assembly: AssemblyCopyright("Copyright © 2017-2019 Frank Skare (stax76)")] [assembly: AssemblyTrademark("")] diff --git a/mpv.net/Resources/mpvNetConfToml.txt b/mpv.net/Resources/mpvNetConfToml.txt index 0652c4b..d4e5e00 100644 --- a/mpv.net/Resources/mpvNetConfToml.txt +++ b/mpv.net/Resources/mpvNetConfToml.txt @@ -17,7 +17,7 @@ help = "Whitelist to monitor the clipboard for URLs to play.\n\nDefault: tube vi name = "process-instance" default = "single" filter = "mpv.net" -help = "Defines if more then one mpv.net process is allowed." +help = "Defines if more then one mpv.net process is allowed.\n\nTip: Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist." options = [{ name = "multi", help = "Create a new process everytime the shell starts mpv.net" }, { name = "single", help = "Force a single process everytime the shell starts mpv.net" }, { name = "queue", help = "Force a single process and add files to playlist" }] diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 73820d1..cfe20e4 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -163,7 +163,7 @@ namespace mpvnet { string dummy = ConfFolder; LoadLibrary("mpv-1.dll"); - Handle = mpv_create(); + Handle = mpv_create(); set_property_string("osc", "yes"); set_property_string("config", "yes"); set_property_string("wid", MainForm.Hwnd.ToString()); @@ -179,23 +179,22 @@ namespace mpvnet public static void LoadScripts() { - string[] jsLua = { ".lua", ".js" }; string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts"); - foreach (var scriptPath in startupScripts) - if (jsLua.Contains(Path.GetExtension(scriptPath).ToLower())) + foreach (string scriptPath in startupScripts) + if (scriptPath.EndsWith(".lua") || scriptPath.EndsWith(".js")) commandv("load-script", $"{scriptPath}"); - foreach (var scriptPath in startupScripts) + foreach (string scriptPath in startupScripts) if (Path.GetExtension(scriptPath) == ".py") PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); - foreach (var scriptPath in startupScripts) + foreach (string scriptPath in startupScripts) if (Path.GetExtension(scriptPath) == ".ps1") PowerShellScript.Init(scriptPath); if (Directory.Exists(ConfFolder + "Scripts")) - foreach (var scriptPath in Directory.GetFiles(ConfFolder + "Scripts")) + foreach (string scriptPath in Directory.GetFiles(ConfFolder + "Scripts")) if (Path.GetExtension(scriptPath) == ".py") PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); else if (Path.GetExtension(scriptPath) == ".ps1") @@ -274,11 +273,11 @@ namespace mpvnet var client_messageData = (mpv_event_client_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_client_message)); string[] args = NativeUtf8StrArray2ManagedStrArray(client_messageData.args, client_messageData.num_args); - if (args != null && args.Length > 1 && args[0] == "mpv.net") + if (args.Length > 1 && args[0] == "mpv.net") { bool found = false; - foreach (var i in mpvnet.Command.Commands) + foreach (Command i in Command.Commands) { if (args[1] == i.Name) { @@ -293,7 +292,8 @@ namespace mpvnet Msg.ShowError($"No command '{args[1]}' found.", $"Available commands are:\n\n{string.Join("\n", names)}\n\nHow to bind these commands can be seen in the [default input bindings and menu definition](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt)."); } } - ClientMessage?.Invoke(args); + else if (args.Length > 0) + ClientMessage?.Invoke(args); break; case mpv_event_id.MPV_EVENT_VIDEO_RECONFIG: VideoReconfig?.Invoke(); @@ -603,16 +603,16 @@ namespace mpvnet return rootPointer; } - static string[] NativeUtf8StrArray2ManagedStrArray(IntPtr pUnmanagedStringArray, int StringCount) + static string[] NativeUtf8StrArray2ManagedStrArray(IntPtr unmanagedStringArray, int StringCount) { - IntPtr[] pIntPtrArray = new IntPtr[StringCount]; - string[] ManagedStringArray = new string[StringCount]; - Marshal.Copy(pUnmanagedStringArray, pIntPtrArray, 0, StringCount); + IntPtr[] intPtrArray = new IntPtr[StringCount]; + string[] stringArray = new string[StringCount]; + Marshal.Copy(unmanagedStringArray, intPtrArray, 0, StringCount); for (int i = 0; i < StringCount; i++) - ManagedStringArray[i] = StringFromNativeUtf8(pIntPtrArray[i]); + stringArray[i] = StringFromNativeUtf8(intPtrArray[i]); - return ManagedStringArray; + return stringArray; } static string StringFromNativeUtf8(IntPtr nativeUtf8)