diff --git a/docs/changelog.md b/docs/changelog.md index 9a4eed5..c927ad4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -7,7 +7,7 @@ the .NET 6 platform. There are user scripts as replacement: [command_palette](https://github.com/stax76/mpv-scripts#command_palette) or [search_menu](https://github.com/stax76/mpv-scripts#search_menu). - Unfortunately the user scripts don't support IME mode which is a problem for asian users. + Unfortunately the user scripts don't support IME mode which is a problem for Asian users. - The blue mpv.net logo was removed for better mpv compatibility. - Fix message box exceding working area size. - C# and PowerShell scripting was removed because of a compatibility problem @@ -25,8 +25,14 @@ - Various improvements and fixes in the input bindings editor. - Automated nightly portable builds (thx to dyphire). - Various new or changed default bindings. -- Context menu and message boxes are available in the languages German, - it can be enabled with the new option `language`. +- Context menu and message boxes are available in the languages Chinese and German. + Interested joining our translation team?: https://app.transifex.com/stax76/teams/ +- Support for encoding mode and thumbfast. +- For script authors the following info is available in user-data: + user-data/frontend/name=mpv.net + user-data/frontend/version=7.0.0.0 + user-data/frontend/process-path=the process path +- MediaInfo 23.11 - libmpv zhongfly 2023-11-03. # v6.0.3.2 Beta (2022-10-14) diff --git a/docs/manual.md b/docs/manual.md index bc345a2..e2ead78 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -253,7 +253,7 @@ Shows the about dialog. Shows available audio devices in a message box. ### show-commands -Shows available mpv input commands. +Shows available [mpv input commands](https://mpv.io/manual/master/#list-of-input-commands). ### show-conf-editor Shows the conf editor. @@ -286,6 +286,15 @@ Shows media info with raw property names. ### show-menu Shows the context menu. +### show-playlist +Shows the playlist in a message box. For a playlist menu +the following user scripts exist: + +- https://github.com/stax76/mpv-scripts#command_palette +- https://github.com/stax76/mpv-scripts#search_menu +- https://github.com/tomasklaen/uosc +- https://github.com/jonniek/mpv-playlistmanager + ### show-profiles Shows available profiles with a message box. @@ -432,6 +441,9 @@ Enable this only when a developer asks for it. Default: no User interface display language. mpv.net must be restarted after a change. +Interested joining our translation team?: +https://app.transifex.com/stax76/teams/ + #### --dark-mode=\ Enables a dark theme. diff --git a/src/MpvNet.Windows/GuiCommand.cs b/src/MpvNet.Windows/GuiCommand.cs index 81509fd..df55823 100644 --- a/src/MpvNet.Windows/GuiCommand.cs +++ b/src/MpvNet.Windows/GuiCommand.cs @@ -1,12 +1,12 @@  +using System.Text; using System.Text.RegularExpressions; +using System.Globalization; using System.Windows.Forms; using System.Windows.Interop; using System.Windows; -using System.Globalization; using MpvNet.ExtensionMethod; -using MpvNet.Help; using MpvNet.Windows.WinForms; using MpvNet.Windows.WPF.Views; using MpvNet.Windows.WPF; @@ -20,7 +20,6 @@ public class GuiCommand public event Action? ScaleWindow; public event Action? MoveWindow; - public event Action? WindowScaleMpv; public event Action? WindowScaleNet; public event Action? ShowMenu; @@ -45,14 +44,13 @@ 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(), // deprecated ["show-info"] = args => ShowMediaInfo(new[] { "osd" }), // deprecated ["quick-bookmark"] = args => QuickBookmark(), // deprecated - ["show-commands"] = args => ShowCommands(), // deprecated ["show-history"] = args => ShowHistory(), // deprecated - ["show-playlist"] = args => ShowPlaylist(), // deprecated ["show-command-palette"] = args => ShowCommandPalette(), // deprecated }; @@ -250,7 +248,7 @@ public class GuiCommand text = text.TrimEx(); if (editor) - ShowTextWithEditor("media-info", text); + Command.ShowTextWithEditor("media-info", text); else if (osd) Command.ShowText(text.Replace("\r", ""), 5000, 16); else @@ -263,53 +261,62 @@ public class GuiCommand public static string FormatTime(double value) => ((int)value).ToString("00"); - public void ShowTextWithEditor(string name, string text) + public void ShowBindings() => Command.ShowTextWithEditor("Bindings", Player.UsedInputConfContent); + + public void ShowPlaylist() { - string file = Path.Combine(Path.GetTempPath(), name + ".txt"); - App.TempFiles.Add(file); - File.WriteAllText(file, BR + text.Trim() + BR); - ProcessHelp.ShellExecute(file); + 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); + } + + string header = BR + "For a playlist menu the following user scripts exist:" + 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; + + Msg.ShowInfo(header + sb.ToString().TrimEnd()); } - public void ShowBindings() - { - string info = "# mpv.net might modify the input.conf content before it is passed to mpv." + BR + - "# Below are the bindings as they were passed to mpv." + BR2; - - ShowTextWithEditor("Bindings", info + Player.UsedInputConfContent); - } - - //public void ShowCommandPalette() - //{ - // MainForm.Instance?.BeginInvoke(() => { - // CommandPalette.Instance.SetItems(CommandPalette.GetItems()); - // MainForm.Instance.ShowCommandPalette(); - // CommandPalette.Instance.SelectFirst(); - // }); - //} - // deprecated public void QuickBookmark() => Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" + "https://github.com/stax76/mpv-scripts/blob/main/misc.lua"); - // deprecated - public void ShowCommands() => - Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" + - "https://github.com/stax76/mpv-scripts#command_palette"); - // deprecated public void ShowHistory() => Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" + "https://github.com/stax76/mpv-scripts/blob/main/history.lua"); - // deprecated - public void ShowPlaylist() => - Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" + - "https://github.com/stax76/mpv-scripts#command_palette"); - // deprecated public void ShowCommandPalette() => - Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" + - "https://github.com/stax76/mpv-scripts#command_palette"); + 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"); } + + + +//public void ShowCommandPalette() +//{ +// MainForm.Instance?.BeginInvoke(() => { +// CommandPalette.Instance.SetItems(CommandPalette.GetItems()); +// MainForm.Instance.ShowCommandPalette(); +// CommandPalette.Instance.SelectFirst(); +// }); +//} \ No newline at end of file diff --git a/src/MpvNet.Windows/Program.cs b/src/MpvNet.Windows/Program.cs index 444cd9d..8312558 100644 --- a/src/MpvNet.Windows/Program.cs +++ b/src/MpvNet.Windows/Program.cs @@ -1,5 +1,4 @@  -using System.Globalization; using System.Windows.Forms; using System.Threading; @@ -8,6 +7,7 @@ using MpvNet.Help; using MpvNet.Windows.UI; using MpvNet.Windows.Help; using MpvNet.Windows.WPF; +using System.Diagnostics; namespace MpvNet.Windows; @@ -42,8 +42,12 @@ static class Program Theme.Init(); Mutex mutex = new Mutex(true, StringHelp.GetMD5Hash(App.ConfPath), out bool isFirst); - if (Control.ModifierKeys.HasFlag(Keys.Shift)) + if (Control.ModifierKeys.HasFlag(Keys.Shift) || + App.CommandLine.Contains("--process-instance=multi") || + App.CommandLine.Contains("--o=")) + { App.ProcessInstance = "multi"; + } if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst) { @@ -93,7 +97,17 @@ static class Program return; } - Application.Run(new WinForms.MainForm()); + if (App.CommandLine.Contains("--o=")) + { + App.AutoLoadFolder = false; + Player.Init(IntPtr.Zero); + Player.ProcessCommandLine(false); + Player.SetPropertyString("idle", "no"); + Player.EventLoop(); + Player.Destroy(); + } + else + Application.Run(new WinForms.MainForm()); if (App.IsTerminalAttached) WinApi.FreeConsole(); diff --git a/src/MpvNet.Windows/Resources/editor_conf.txt b/src/MpvNet.Windows/Resources/editor_conf.txt index 1830bd8..6eab226 100644 --- a/src/MpvNet.Windows/Resources/editor_conf.txt +++ b/src/MpvNet.Windows/Resources/editor_conf.txt @@ -522,7 +522,8 @@ name = language file = mpvnet default = system directory = UI -help = User interface display language.\nmpv.net must be restarted after a change. +help = User interface display language.\nmpv.net must be restarted after a change.\nInterested joining our translation team?: +url = https://app.transifex.com/stax76/teams/ option = system option = english option = chinese-china diff --git a/src/MpvNet.Windows/WPF/Controls/HyperlinkEx.cs b/src/MpvNet.Windows/WPF/Controls/HyperlinkEx.cs index df6ce2a..638d92b 100644 --- a/src/MpvNet.Windows/WPF/Controls/HyperlinkEx.cs +++ b/src/MpvNet.Windows/WPF/Controls/HyperlinkEx.cs @@ -9,10 +9,8 @@ namespace MpvNet.Windows.WPF; public class HyperlinkEx : Hyperlink { - void HyperLinkEx_RequestNavigate(object sender, RequestNavigateEventArgs e) - { + void HyperLinkEx_RequestNavigate(object sender, RequestNavigateEventArgs e) => ProcessHelp.ShellExecute(e.Uri.AbsoluteUri); - } public void SetURL(string? url) { diff --git a/src/MpvNet.Windows/WPF/Resources.xaml b/src/MpvNet.Windows/WPF/Resources.xaml index 666c04f..5cada96 100644 --- a/src/MpvNet.Windows/WPF/Resources.xaml +++ b/src/MpvNet.Windows/WPF/Resources.xaml @@ -3,8 +3,18 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:hc="clr-namespace:HandyControl.Controls" xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" + xmlns:local="clr-namespace:MpvNet.Windows.WPF" > + +