From 3970d5c0c2ad8fe97dcd4841d9e986ae08adc33d Mon Sep 17 00:00:00 2001 From: stax76 Date: Tue, 2 Jan 2024 09:09:16 +0100 Subject: [PATCH] v7.0.0.6 Beta --- docs/changelog.md | 5 + docs/manual.md | 15 +++ src/MpvNet.Windows/GuiCommand.cs | 113 +++++++++++++---------- src/MpvNet.Windows/MpvNet.Windows.csproj | 6 +- src/MpvNet/Command.cs | 22 ++--- src/MpvNet/InputConf.cs | 35 ++++++- src/MpvNet/InputHelp.cs | 7 +- src/MpvNet/Player.cs | 1 + src/MpvNet/Settings.cs | 1 + src/Setup/Inno/inno-setup.iss | 2 +- 10 files changed, 136 insertions(+), 71 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 76ec7cda..cba72755 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,4 +1,9 @@ +# v7.0.0.6 Beta (2023-01-02) + +- Improved backward compatibility with input.conf files created by old versions. + + # v7.0.0.5 Beta (2023-12-28) - Fix mpv.net option `language` not working from command line. diff --git a/docs/manual.md b/docs/manual.md index e102c90c..2a1dc023 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -270,6 +270,21 @@ Shows available audio devices in a message box. ### show-commands Shows available [mpv input commands](https://mpv.io/manual/master/#list-of-input-commands). +### show-properties +Shows available [properties](https://mpv.io/manual/master/#properties). + +### show-keys +Shows available [input keys](https://mpv.io/manual/master/#options-input-keylist). + +### show-protocols +Shows available [protocols](https://mpv.io/manual/master/#options-list-protocols). + +### show-decoders +Shows available decoders. + +### show-demuxers +Shows available demuxers. + ### show-conf-editor Shows the conf editor. diff --git a/src/MpvNet.Windows/GuiCommand.cs b/src/MpvNet.Windows/GuiCommand.cs index b6addc05..7c484d49 100644 --- a/src/MpvNet.Windows/GuiCommand.cs +++ b/src/MpvNet.Windows/GuiCommand.cs @@ -1,5 +1,6 @@  using System.Text; +using System.Text.Json; using System.Text.RegularExpressions; using System.Globalization; using System.Windows.Forms; @@ -11,9 +12,8 @@ using MpvNet.Windows.WPF.Views; using MpvNet.Windows.WPF; using MpvNet.Windows.WPF.MsgBox; -using MpvNet.Help; -using System.Text.Json; using MpvNet.Windows.Help; +using MpvNet.Help; namespace MpvNet; @@ -47,27 +47,35 @@ public class GuiCommand ["window-scale"] = args => WindowScaleNet?.Invoke(float.Parse(args[0], CultureInfo.InvariantCulture)), ["show-menu"] = args => ShowMenu?.Invoke(), ["show-bindings"] = args => ShowBindings(), - ["show-playlist"] = args => ShowPlaylist(), ["add-to-path"] = args => AddToPath(), ["edit-conf-file"] = EditCongFile, ["show-commands"] = args => ShowCommands(), + ["show-properties"] = args => ShowProperties(), + ["show-keys"] = args => ShowKeys(), + ["show-protocols"] = args => ShowProtocols(), + ["show-decoders"] = args => ShowDecoders(), + ["show-demuxers"] = args => ShowDemuxers(), + ["show-info"] = args => ShowMediaInfo(new[] { "osd" }), // deprecated - ["show-info"] = args => ShowMediaInfo(new[] { "osd" }), // deprecated + ["show-recent"] = args => ShowRemoved(), // deprecated + ["show-playlist"] = args => ShowPlaylist(), // deprecated ["quick-bookmark"] = args => QuickBookmark(), // deprecated ["show-history"] = args => ShowHistory(), // deprecated ["show-command-palette"] = args => ShowCommandPalette(), // deprecated + ["show-audio-tracks"] = args => ShowTracks(), // deprecated + ["show-subtitle-tracks"] = args => ShowTracks(), // deprecated }; - public void ShowDialog(Type winType) + void ShowDialog(Type winType) { Window? win = Activator.CreateInstance(winType) as Window; new WindowInteropHelper(win).Owner = MainForm.Instance!.Handle; win?.ShowDialog(); } - public void LoadSubtitle(IList args) + void LoadSubtitle(IList args) { using var dialog = new OpenFileDialog(); string path = Player.GetPropertyString("path"); @@ -82,7 +90,7 @@ public void LoadSubtitle(IList args) Player.CommandV("sub-add", filename); } - public void OpenFiles(IList args) + void OpenFiles(IList args) { bool append = false; @@ -96,7 +104,7 @@ public void OpenFiles(IList args) Player.LoadFiles(dialog.FileNames, true, append); } - public void Open_DVD_Or_BD_Folder(IList args) + void Open_DVD_Or_BD_Folder(IList args) { var dialog = new FolderBrowserDialog(); @@ -104,7 +112,7 @@ public void Open_DVD_Or_BD_Folder(IList args) Player.LoadDiskFolder(dialog.SelectedPath); } - public void EditCongFile(IList args) + void EditCongFile(IList args) { string file = Player.ConfigFolder + args[0]; @@ -112,7 +120,7 @@ public void EditCongFile(IList args) ProcessHelp.ShellExecute(WinApiHelp.GetAppPathForExtension("txt"), "\"" + file + "\""); } - public static void ShowTextWithEditor(string name, string text) + void ShowTextWithEditor(string name, string text) { string file = Path.Combine(Path.GetTempPath(), name + ".txt"); App.TempFiles.Add(file); @@ -120,7 +128,7 @@ public static void ShowTextWithEditor(string name, string text) ProcessHelp.ShellExecute(WinApiHelp.GetAppPathForExtension("txt"), "\"" + file + "\""); } - public static void ShowCommands() + void ShowCommands() { string json = Core.GetPropertyString("command-list"); var enumerator = JsonDocument.Parse(json).RootElement.EnumerateArray(); @@ -151,7 +159,22 @@ public static void ShowCommands() ShowTextWithEditor("Input Commands", header + sb.ToString()); } - public void OpenFromClipboard(IList args) + void ShowProperties() => + ShowTextWithEditor("Properties", Core.GetPropertyString("property-list").Replace(",", BR)); + + void ShowKeys() => + ShowTextWithEditor("Keys", Core.GetPropertyString("input-key-list").Replace(",", BR)); + + void ShowProtocols() => + ShowTextWithEditor("Protocols", Core.GetPropertyString("protocol-list").Replace(",", BR)); + + void ShowDecoders() => + ShowTextWithEditor("Decoders", Core.GetPropertyOsdString("decoder-list").Replace(",", BR)); + + void ShowDemuxers() => + ShowTextWithEditor("Demuxers", Core.GetPropertyOsdString("demuxer-lavf-list").Replace(",", BR)); + + void OpenFromClipboard(IList args) { bool append = args.Count == 1 && args[0] == "append"; @@ -185,7 +208,7 @@ public void OpenFromClipboard(IList args) } } - public void LoadAudio(IList args) + void LoadAudio(IList args) { using var dialog = new OpenFileDialog(); string path = Player.GetPropertyString("path"); @@ -200,7 +223,7 @@ public void LoadAudio(IList args) Player.CommandV("audio-add", i); } - public void RegisterFileAssociations(IList args) + void RegisterFileAssociations(IList args) { string perceivedType = args[0]; string[] extensions = Array.Empty(); @@ -238,7 +261,7 @@ public void RegisterFileAssociations(IList args) catch { } } - public void ShowMediaInfo(IList args) + void ShowMediaInfo(IList args) { if (Player.PlaylistPos == -1) return; @@ -320,11 +343,11 @@ public void ShowMediaInfo(IList args) } } - public static string FormatTime(double value) => ((int)value).ToString("00"); + string FormatTime(double value) => ((int)value).ToString("00"); - public void ShowBindings() => ShowTextWithEditor("Bindings", Player.UsedInputConfContent); + void ShowBindings() => ShowTextWithEditor("Bindings", Player.UsedInputConfContent); - public void AddToPath() + void AddToPath() { string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!; @@ -341,55 +364,43 @@ public void AddToPath() Msg.ShowInfo(_("mpv.net was successfully added to Path.")); } - public void ShowPlaylist() - { - var count = Player.GetPropertyInt("playlist-count"); - - if (count < 1) - return; - - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < count; i++) - { - string name = Player.GetPropertyString($"playlist/{i}/title"); - - if (string.IsNullOrEmpty(name)) - name = Player.GetPropertyString($"playlist/{i}/filename").FileName(); - - sb.AppendLine(name); - } + // deprecated + void ShowTracks() => + Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 + + "https://github.com/stax76/mpv-scripts#command_palette" + BR + + "https://github.com/stax76/mpv-scripts#search_menu" + BR + + "https://github.com/tomasklaen/uosc"); - string header = BR + "For a playlist menu the following user scripts exist:" + BR2 + + // deprecated + void ShowPlaylist() => + Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 + "https://github.com/stax76/mpv-scripts#command_palette" + BR + "https://github.com/stax76/mpv-scripts#search_menu" + BR + "https://github.com/tomasklaen/uosc" + BR + - "https://github.com/jonniek/mpv-playlistmanager" + BR2; + "https://github.com/jonniek/mpv-playlistmanager"); - Msg.ShowInfo(header + sb.ToString().TrimEnd()); - } + // deprecated + void ShowCommandPalette() => + Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 + + "https://github.com/stax76/mpv-scripts#command_palette" + BR + + "https://github.com/stax76/mpv-scripts#search_menu" + BR + + "https://github.com/tomasklaen/uosc"); // deprecated - public void QuickBookmark() => - Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" + + void QuickBookmark() => + Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 + "https://github.com/stax76/mpv-scripts/blob/main/misc.lua"); // deprecated - public void ShowHistory() => - Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" + + void ShowHistory() => + Msg.ShowInfo(_("This feature was removed, but there are user scripts:") + BR2 + "https://github.com/stax76/mpv-scripts/blob/main/history.lua"); // deprecated - public void ShowCommandPalette() => - Msg.ShowInfo( - "This feature was removed but is still available in the form of user scripts:" + BR2 + - "https://github.com/stax76/mpv-scripts#command_palette" + BR + - "https://github.com/stax76/mpv-scripts#search_menu" + BR + - "https://github.com/tomasklaen/uosc"); + void ShowRemoved() => Msg.ShowInfo(_("This feature was removed.")); } - //public void ShowCommandPalette() //{ // MainForm.Instance?.BeginInvoke(() => { diff --git a/src/MpvNet.Windows/MpvNet.Windows.csproj b/src/MpvNet.Windows/MpvNet.Windows.csproj index a6138499..e843f303 100644 --- a/src/MpvNet.Windows/MpvNet.Windows.csproj +++ b/src/MpvNet.Windows/MpvNet.Windows.csproj @@ -11,9 +11,9 @@ true mpv-icon.ico mpv.net - 7.0.0.5 - 7.0.0.5 - 7.0.0.5 + 7.0.0.6 + 7.0.0.6 + 7.0.0.6 enable diff --git a/src/MpvNet/Command.cs b/src/MpvNet/Command.cs index d30c87a7..0c83ec6b 100644 --- a/src/MpvNet/Command.cs +++ b/src/MpvNet/Command.cs @@ -1,7 +1,5 @@  using System.Globalization; -using System.Text; -using System.Text.Json; using MpvNet.Help; namespace MpvNet; @@ -26,13 +24,13 @@ public class Command // deprecated ["playlist-add"] = args => PlaylistAdd(Convert.ToInt32(args[0])), // deprecated - ["show-progress"] = args => ShowProgress(), // deprecated + ["show-progress"] = args => Player.Command("show-progress"), // deprecated ["playlist-random"] = args => PlaylistRandom(), // deprecated }; - public string FormatTime(double value) => ((int)value).ToString("00"); + string FormatTime(double value) => ((int)value).ToString("00"); - public static void PlayPause(IList args) + void PlayPause(IList args) { int count = Player.GetPropertyInt("playlist-count"); @@ -66,7 +64,7 @@ public static void ShowText(string text, int duration = 0, int fontSize = 0) "}${osd-ass-cc/1}" + text + "\" " + duration); } - public static void CycleAudio() + void CycleAudio() { Player.UpdateExternalTracks(); @@ -94,7 +92,7 @@ public static void CycleAudio() } } - public static void CycleSubtitles() + void CycleSubtitles() { Player.UpdateExternalTracks(); @@ -126,7 +124,7 @@ public static void CycleSubtitles() } // deprecated - public static void PlaylistAdd(int value) + void PlaylistAdd(int value) { int pos = Player.PlaylistPos; int count = Player.GetPropertyInt("playlist-count"); @@ -145,13 +143,13 @@ public static void PlaylistAdd(int value) Player.SetPropertyInt("playlist-pos", pos); } - public static void PlaylistFirst() + void PlaylistFirst() { if (Player.PlaylistPos != 0) Player.SetPropertyInt("playlist-pos", 0); } - public static void PlaylistLast() + void PlaylistLast() { int count = Player.GetPropertyInt("playlist-count"); @@ -160,14 +158,14 @@ public static void PlaylistLast() } // deprecated - public static void PlaylistRandom() + void PlaylistRandom() { int count = Player.GetPropertyInt("playlist-count"); Player.SetPropertyInt("playlist-pos", new Random().Next(count)); } // deprecated - public void ShowProgress() + void ShowProgress() { TimeSpan position = TimeSpan.FromSeconds(Player.GetPropertyDouble("time-pos")); TimeSpan duration = TimeSpan.FromSeconds(Player.GetPropertyDouble("duration")); diff --git a/src/MpvNet/InputConf.cs b/src/MpvNet/InputConf.cs index 81f2efd1..2b456dcb 100644 --- a/src/MpvNet/InputConf.cs +++ b/src/MpvNet/InputConf.cs @@ -1,5 +1,4 @@  -using MpvNet.ExtensionMethod; using MpvNet.Help; namespace MpvNet; @@ -15,8 +14,11 @@ public class InputConf public string Path { get => _path ?? ""; set { - _path = value; - Content = File.Exists(_path) ? FileHelp.ReadTextFile(_path) : ""; + if (_path != value) + { + _path = value; + Content = File.Exists(_path) ? FileHelp.ReadTextFile(_path) : ""; + } } } @@ -50,7 +52,29 @@ public string Path { public string GetContent() { if (HasMenu) + { + try + { + if (App.Settings.MenuUpdateVersion != 1) + { + string updatedContent = UpdateContent(Content); + + if (updatedContent != Content) + { + File.Copy(Path, Path + ".backup", true); + File.WriteAllText(Path, Content = updatedContent); + } + + App.Settings.MenuUpdateVersion = 1; + } + } + catch (Exception ex) + { + Terminal.WriteError("Failed to update menu." + BR + ex.Message); + } + return Content; + } else { var defaults = InputHelp.GetDefaults(); @@ -73,4 +97,9 @@ public string GetContent() return InputHelp.ConvertToString(defaults); } } + + static string UpdateContent(string content) => content + .Replace("script-message mpv.net", "script-message-to mpvnet") + .Replace("/docs/Manual.md", "/docs/manual.md") + .Replace("https://github.com/stax76/mpv.net", "https://github.com/mpvnet-player/mpv.net"); } diff --git a/src/MpvNet/InputHelp.cs b/src/MpvNet/InputHelp.cs index f9c0241a..cdf2472e 100644 --- a/src/MpvNet/InputHelp.cs +++ b/src/MpvNet/InputHelp.cs @@ -127,6 +127,11 @@ public static List GetDefaults() new (_("View") + " > " + _("More"), _("Show Audio Devices"), "script-message-to mpvnet show-audio-devices"), new (_("View") + " > " + _("More"), _("Show Commands"), "script-message-to mpvnet show-commands", "F2"), new (_("View") + " > " + _("More"), _("Show Bindings"), "script-message-to mpvnet show-bindings"), + new (_("View") + " > " + _("More"), _("Show Properties"), "script-message-to mpvnet show-properties", "F3"), + new (_("View") + " > " + _("More"), _("Show Keys"), "script-message-to mpvnet show-keys", "Alt+k"), + new (_("View") + " > " + _("More"), _("Show Protocols"), "script-message-to mpvnet show-protocols", "Alt+p"), + new (_("View") + " > " + _("More"), _("Show Decoders"), "script-message-to mpvnet show-decoders", "Alt+d"), + new (_("View") + " > " + _("More"), _("Show Demuxers"), "script-message-to mpvnet show-demuxers"), new (_("Window"), _("Fullscreen"), "cycle fullscreen", "Enter"), new (_("Window") + " > " + _("Zoom"), _("Enlarge"), "script-message-to mpvnet scale-window 1.2", "Alt++"), @@ -483,7 +488,7 @@ public static string GetBindingsForCommand(Dictionary activeBin Binding binding = it.Value; - if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 20 && keys.Count < 2) + if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 15 && keys.Count < 2) { keys.Add(binding.Input); charCount += binding.Input.Length; diff --git a/src/MpvNet/Player.cs b/src/MpvNet/Player.cs index dd9d48bf..b3f1cca1 100644 --- a/src/MpvNet/Player.cs +++ b/src/MpvNet/Player.cs @@ -98,6 +98,7 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true) SetPropertyBool("input-default-bindings", true); SetPropertyBool("input-builtin-bindings", false); + SetPropertyString("idle", "yes"); SetPropertyString("screenshot-directory", "~~desktop/"); SetPropertyString("osd-playing-msg", "${media-title}"); SetPropertyString("osc", "yes"); diff --git a/src/MpvNet/Settings.cs b/src/MpvNet/Settings.cs index ae8d2575..dcc1507d 100644 --- a/src/MpvNet/Settings.cs +++ b/src/MpvNet/Settings.cs @@ -11,6 +11,7 @@ public class AppSettings { public bool InputDefaultBindingsFixApplied; public bool ShowMenuFixApplied; + public int MenuUpdateVersion; public int Volume = 70; public List RecentFiles = new List(); public Point WindowLocation; diff --git a/src/Setup/Inno/inno-setup.iss b/src/Setup/Inno/inno-setup.iss index 6cb0a737..2d5eadb8 100644 --- a/src/Setup/Inno/inno-setup.iss +++ b/src/Setup/Inno/inno-setup.iss @@ -25,4 +25,4 @@ Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" [Files] Source: "{#MyAppSourceDir}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; +Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Excludes: "win-x64"; Flags: ignoreversion recursesubdirs createallsubdirs;