From cedd694e8e2e54a848c03212f2b3a6f059257fce Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Mon, 1 Jul 2019 02:45:22 +0200 Subject: [PATCH] - --- Changelog.md | 7 +++++-- mpv.net/Misc/Command.cs | 4 ++-- mpv.net/Misc/Program.cs | 2 +- mpv.net/Properties/AssemblyInfo.cs | 4 ++-- mpv.net/Resources/inputConf.txt | 2 +- mpv.net/Resources/mpvConfToml.txt | 8 ++++++++ mpv.net/Resources/mpvNetConfToml.txt | 14 +++++++------- mpv.net/WinForms/MainForm.cs | 11 ++++++----- mpv.net/mpv/mp.cs | 9 +++++---- 9 files changed, 37 insertions(+), 24 deletions(-) diff --git a/Changelog.md b/Changelog.md index 989f2d61..c2829dd6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,4 @@ -### +### 4.5 - opening a URL manually no longer uses a input box but uses the clipboard directly - the manifest was missing the company attribute which caused @@ -10,7 +10,10 @@ - a description on how to start mpv.net from Google Chrome was added to the manual, it's useful to play videos from sites like YouTube, find the description [here](https://github.com/stax76/mpv.net/blob/master/Manual.md#chrome-extension) - +- new config setting remember-height added to remember the window height, + otherwise the video's native resolution is used +- support for protocols other then http added + ### 4.4 - clipboard-monitoring was replaced by url-whitelist: diff --git a/mpv.net/Misc/Command.cs b/mpv.net/Misc/Command.cs index b8152dea..9c679894 100644 --- a/mpv.net/Misc/Command.cs +++ b/mpv.net/Misc/Command.cs @@ -219,9 +219,9 @@ public static void open_url(string[] args) { MainForm.Instance.Invoke(new Action(() => { string clipboard = Clipboard.GetText(); - if (string.IsNullOrEmpty(clipboard) || !clipboard.Contains("://") || clipboard.Contains("\n") || clipboard.Contains(" ")) + if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) || clipboard.Contains("\n")) { - Msg.ShowError("The clipboard does not contain a valid URL, it has to contain :// and is not allowed to contain a newline or space character."); + Msg.ShowError("The clipboard does not contain a valid URL or file, URLs have to contain :// and is not allowed to contain a newline character."); return; } mp.Load(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control)); diff --git a/mpv.net/Misc/Program.cs b/mpv.net/Misc/Program.cs index d1ea95c4..5381e78b 100644 --- a/mpv.net/Misc/Program.cs +++ b/mpv.net/Misc/Program.cs @@ -33,7 +33,7 @@ static void Main() List files = new List(); foreach (string arg in args) - if (!arg.StartsWith("--") && (File.Exists(arg) || arg == "-" || arg.StartsWith("http"))) + if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || File.Exists(arg))) files.Add(arg); if (files.Count > 0) diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index ded9d0bd..c744f42c 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 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("4.4.0.0")] -[assembly: AssemblyFileVersion("4.4.0.0")] +[assembly: AssemblyVersion("4.5.0.0")] +[assembly: AssemblyFileVersion("4.5.0.0")] diff --git a/mpv.net/Resources/inputConf.txt b/mpv.net/Resources/inputConf.txt index 66646999..5a825451 100644 --- a/mpv.net/Resources/inputConf.txt +++ b/mpv.net/Resources/inputConf.txt @@ -25,7 +25,7 @@ # mpv input keys: https://github.com/stax76/mpv.net/wiki/mpv-input-keys o script-message mpv.net open-files #menu: Open > Open Files... - u script-message mpv.net open-url #menu: Open > Open URL... + u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard _ ignore #menu: Open > - Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files... Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files... diff --git a/mpv.net/Resources/mpvConfToml.txt b/mpv.net/Resources/mpvConfToml.txt index 9b9f41a0..379cd145 100644 --- a/mpv.net/Resources/mpvConfToml.txt +++ b/mpv.net/Resources/mpvConfToml.txt @@ -254,6 +254,14 @@ default = "50%" filter = "Screen" help = "Set the initial window size in percent. Please note that this setting is only partly implemented in mpv.net, accepted are only integer values with percent sign added. Default: 50%" +[[settings]] +name = "remember-height" +default = "yes" +filter = "Screen" +help = "mpv.net specific setting to remember the window height, otherwise the video's native resolution is used." +options = [{ name = "yes" }, + { name = "no" }] + [[settings]] name = "keep-open-pause" default = "yes" diff --git a/mpv.net/Resources/mpvNetConfToml.txt b/mpv.net/Resources/mpvNetConfToml.txt index d4e5e00e..eedd81e5 100644 --- a/mpv.net/Resources/mpvNetConfToml.txt +++ b/mpv.net/Resources/mpvNetConfToml.txt @@ -1,7 +1,7 @@ [[settings]] name = "dark-mode" default = "always" -filter = "mpv.net" +filter = "General" help = "Enables a dark theme." options = [{ name = "always" }, { name = "system" , help = "Available on Windows 10 or higher" }, @@ -9,15 +9,15 @@ options = [{ name = "always" }, [[settings]] name = "url-whitelist" -filter = "mpv.net" +filter = "General" type = "string" -help = "Whitelist to monitor the clipboard for URLs to play.\n\nDefault: tube vimeo ard zdf" +help = "mpv.net specific whitelist setting to monitor the clipboard for URLs to play.\n\nDefault: tube vimeo ard zdf" [[settings]] name = "process-instance" default = "single" -filter = "mpv.net" -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." +filter = "General" +help = "mpv.net specific setting that 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" }] @@ -25,7 +25,7 @@ options = [{ name = "multi", help = "Create a new process everytime the shell s [[settings]] name = "debug-mode" default = "no" -filter = "mpv.net" -help = "Writes debug info to a file located on the desktop." +filter = "General" +help = "mpv.net specific setting that writes debug info to a file located on the desktop." options = [{ name = "yes" }, { name = "no" }] \ No newline at end of file diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index f9c93873..5e3162ef 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -64,7 +64,7 @@ public MainForm() void CM_Popup(object sender, EventArgs e) => CursorHelp.Show(); - void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSizeKeepHeight())); + void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSize())); void Shutdown() => BeginInvoke(new Action(() => Close())); @@ -222,11 +222,12 @@ void SetStartFormPositionAndSize() Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */); } - void SetFormPosAndSizeKeepHeight() + void SetFormPosAndSize() { if (IsFullscreen || mp.VideoSize.Width == 0) return; Screen screen = Screen.FromControl(this); - int height = ClientSize.Height; + int height = mp.VideoSize.Height; + if (mp.RememberHeight) height = ClientSize.Height; if (height > screen.Bounds.Height * 0.9) height = Convert.ToInt32(screen.Bounds.Height * mp.Autofit); int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.Height); Point middlePos = new Point(Left + Width / 2, Top + Height / 2); @@ -272,7 +273,7 @@ private void FileLoaded() { string path = mp.get_property_string("path"); BeginInvoke(new Action(() => { - if (File.Exists(path) || path.StartsWith("http")) + if (File.Exists(path) || path.Contains("://")) Text = Path.GetFileName(path) + " - mpv.net " + Application.ProductVersion; else Text = "mpv.net " + Application.ProductVersion; @@ -311,7 +312,7 @@ public void CycleFullscreen(bool enabled) else FormBorderStyle = FormBorderStyle.None; - SetFormPosAndSizeKeepHeight(); + SetFormPosAndSize(); } } diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 2019f2b2..7928b5b1 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -72,11 +72,12 @@ public class mp public static bool Fullscreen { get; set; } public static bool Border { get; set; } = true; + public static bool RememberHeight { get; set; } = true; public static int Screen { get; set; } = -1; public static int Edition { get; set; } - public static float Autofit { get; set; } = 0.50f; + public static float Autofit { get; set; } = 0.5f; public static void ProcessProperty(string name, string value) { @@ -91,6 +92,7 @@ public static void ProcessProperty(string name, string value) case "fullscreen": Fullscreen = value == "yes"; break; case "border": Border = value == "yes"; break; case "screen": Screen = Convert.ToInt32(value); break; + case "remember-height": RememberHeight = value == "yes"; break; } } @@ -524,11 +526,10 @@ protected static void ProcessCommandLine() foreach (string i in args) { - if (!i.StartsWith("--") && (i == "-" || i.StartsWith("http") || File.Exists(i))) + if (!i.StartsWith("--") && (i == "-" || i.Contains("://") || File.Exists(i))) { files.Add(i); - if (i.StartsWith("http")) - RegHelp.SetObject(App.RegPath, "LastURL", i); + if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i); } }