diff --git a/Changelog.md b/Changelog.md index f8d7f60..d0a6fdf 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,7 +8,7 @@ - The code from the included JavaScript file was ported into the core player because JavaScript is currently broken in the builds of shinshiro. - MediaInfo 21.3 -- libmpv 2021-02-28 +- libmpv shinchiro 2021-04-04 5.4.8.7 Beta (2021-03-09) diff --git a/Manual.md b/Manual.md index f4b660e..7209f28 100644 --- a/Manual.md +++ b/Manual.md @@ -492,17 +492,13 @@ The documentation of mpvs window features can be found here: mpv.net has currently implemented the following window features: -[screen](https://mpv.io/manual/master/#options-screen) - -[fullscreen](https://mpv.io/manual/master/#options-fullscreen) - -[ontop](https://mpv.io/manual/master/#options-ontop) - -[border](https://mpv.io/manual/master/#options-border) - -[window-minimized](https://mpv.io/manual/master/#options-window-minimized) - -[window-maximized](https://mpv.io/manual/master/#options-window-maximized) +- [border](https://mpv.io/manual/master/#options-border) +- [fullscreen](https://mpv.io/manual/master/#options-fullscreen) +- [ontop](https://mpv.io/manual/master/#options-ontop) +- [screen](https://mpv.io/manual/master/#options-screen) +- [title](https://mpv.io/manual/master/#options-title) +- [window-maximized](https://mpv.io/manual/master/#options-window-maximized) +- [window-minimized](https://mpv.io/manual/master/#options-window-minimized) **Partly implemented are:** diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index df8d069..36c7ef3 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -49,10 +49,6 @@ namespace mpvnet Hwnd = Handle; ConsoleHelp.Padding = 60; core.Init(); - core.Title = core.get_property_string("title"); - - if (core.Title != null && core.Title.EndsWith("} - mpv")) - core.Title = ""; if (App.GlobalMediaKeys) { @@ -92,7 +88,6 @@ namespace mpvnet Application.ThreadException += (sender, e) => App.ShowException(e.Exception); Msg.SupportURL = "https://github.com/stax76/mpv.net#support"; - Text = string.IsNullOrEmpty(core.Title) ? "mpv.net " + Application.ProductVersion : core.Title; TaskbarButtonCreatedMessage = RegisterWindowMessage("TaskbarButtonCreated"); ContextMenu = new ContextMenuStripEx(components); @@ -167,10 +162,7 @@ namespace mpvnet void Shutdown() => BeginInvoke(new Action(() => Close())); - void Idle() - { - BeginInvoke(new Action(() => Text = string.IsNullOrEmpty(core.Title) ? "mpv.net " + Application.ProductVersion : core.Title)); - } + void Idle() => SetTitle(); bool WasShown() => ShownTickCount != 0 && Environment.TickCount > ShownTickCount + 500; @@ -524,15 +516,7 @@ namespace mpvnet string path = core.get_property_string("path"); BeginInvoke(new Action(() => { - if (string.IsNullOrEmpty(core.Title)) - { - if (path.Contains("://")) - Text = core.get_property_string("media-title") + " - mpv.net " + Application.ProductVersion; - else - Text = path.FileName() + " - mpv.net " + Application.ProductVersion; - } - else - Text = core.Title; + Text = core.expand(Title); int interval = (int)(core.Duration.TotalMilliseconds / 100); @@ -555,6 +539,8 @@ namespace mpvnet RecentFiles.RemoveAt(App.RecentCount); } + void SetTitle() => BeginInvoke(new Action(() => Text = core.expand(Title))); + void SaveWindowProperties() { if (WindowState == FormWindowState.Normal) @@ -573,6 +559,21 @@ namespace mpvnet } } + string _Title; + + public string Title { + get => _Title; + set { + if (string.IsNullOrEmpty(value)) + return; + + if (value.EndsWith("} - mpv")) + value = value.Replace("} - mpv", "} - mpv.net"); + + _Title = value; + } + } + protected override void WndProc(ref Message m) { //Debug.WriteLine(m); @@ -749,11 +750,8 @@ namespace mpvnet void PropChangeSid(string value) => core.Sid = value; void PropChangeVid(string value) => core.Vid = value; - - void PropChangeTitle(string value) => BeginInvoke(new Action(() => { - if (value != null && !value.EndsWith("} - mpv")) - Text = value; - })); + + void PropChangeTitle(string value) { Title = value; SetTitle(); } void PropChangeEdition(int value) => core.Edition = value; diff --git a/mpv.net/mpv/Core.cs b/mpv.net/mpv/Core.cs index 1a1c643..6c0e7e0 100644 --- a/mpv.net/mpv/Core.cs +++ b/mpv.net/mpv/Core.cs @@ -100,7 +100,6 @@ namespace mpvnet public string GPUAPI { get; set; } = "auto"; public string InputConfPath { get => ConfigFolder + "input.conf"; } public string Sid { get; set; } = ""; - public string Title { get; set; } = ""; public string Vid { get; set; } = ""; public bool Border { get; set; } = true; @@ -178,7 +177,6 @@ namespace mpvnet case "taskbar-progress": TaskbarProgress = value == "yes"; break; case "screen": Screen = Convert.ToInt32(value); break; case "gpu-api": GPUAPI = value; break; - case "title": Title = value; break; } if (AutofitLarger > 1) @@ -684,6 +682,12 @@ namespace mpvnet public string expand(string value) { + if (value == null) + return ""; + + if (!value.Contains("${")) + return value; + string[] args = { "expand-text", value }; int count = args.Length + 1; IntPtr[] pointers = new IntPtr[count];