diff --git a/Changelog.md b/Changelog.md index 079dd90..e4ecfcc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,11 +5,13 @@ - new: for URLs the media title is shown in the title bar and the info command instead of displaying the URL, mpv.conf defaults were changed to use [protocol.https] osd-playing-msg = '${media-title}' -- fix: on the very first start volume was set to 0 and mute was set to yes, - now reasonable defaults are set, volume = 70, mute = no + +- fix: on the very first start volume was set to 0 and mute was set to yes - fix: there was a issue fixed with the URL clipboard monitoring - fix: there was a sound when closed from taskbar due to a exception -- update: libmpv shinchiro 2019-09-22 +- fix: the log feature was not working + +- update: libmpv shinchiro 2019-10-06 - update: youtube-dl 2019-10-01 ### 5.4.1.1 diff --git a/extensions/ScriptingExtension/ScriptingExtension.cs b/extensions/ScriptingExtension/ScriptingExtension.cs index 8cc0845..cd552ef 100644 --- a/extensions/ScriptingExtension/ScriptingExtension.cs +++ b/extensions/ScriptingExtension/ScriptingExtension.cs @@ -28,9 +28,9 @@ namespace ScriptingExtension // the file name of extensions must end with 'Exten if (Directory.Exists(mp.ConfigFolder + "scripts")) scriptFiles.AddRange(Directory.GetFiles(mp.ConfigFolder + "scripts", "*.cs")); - if (Directory.Exists(PathHelp.StartupPath + "scripts")) - foreach (string path in Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs")) - scriptFiles.AddRange(Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs")); + if (Directory.Exists(Folder.Startup + "scripts")) + foreach (string path in Directory.GetFiles(Folder.Startup + "scripts", "*.cs")) + scriptFiles.AddRange(Directory.GetFiles(Folder.Startup + "scripts", "*.cs")); if (scriptFiles.Count == 0) return; CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom; diff --git a/mpv.net/Misc/Extension.cs b/mpv.net/Misc/Extension.cs index a954a82..b28ae32 100644 --- a/mpv.net/Misc/Extension.cs +++ b/mpv.net/Misc/Extension.cs @@ -19,7 +19,7 @@ namespace mpvnet try { AggregateCatalog catalog = new AggregateCatalog(); - string dir = PathHelp.StartupPath + "Extensions"; + string dir = Folder.Startup + "Extensions"; if (Directory.Exists(dir)) { diff --git a/mpv.net/Misc/Misc.cs b/mpv.net/Misc/Misc.cs index 3e58380..ba5cc29 100644 --- a/mpv.net/Misc/Misc.cs +++ b/mpv.net/Misc/Misc.cs @@ -291,8 +291,34 @@ namespace mpvnet } } + public class Folder + { + public static string Startup { get; } = Application.StartupPath + "\\"; + } + public class PathHelp { - public static string StartupPath { get; } = Application.StartupPath + "\\"; + public static string GetBaseName(string value) + { + if (string.IsNullOrEmpty(value)) + return ""; + + int index = value.IndexOf("/"); + + if (index > -1) + value = value.Substring(index + 1); + + index = value.IndexOf("\\"); + + if (index > -1) + value = value.Substring(index + 1); + + index = value.LastIndexOf("."); + + if (index > -1) + value = value.Substring(0, index); + + return value; + } } } \ No newline at end of file diff --git a/mpv.net/Native/Native.cs b/mpv.net/Native/Native.cs index ff1c88a..920b411 100644 --- a/mpv.net/Native/Native.cs +++ b/mpv.net/Native/Native.cs @@ -7,7 +7,7 @@ public class Native [DllImport("kernel32.dll")] public static extern bool AttachConsole(int dwProcessId); - [DllImport("kernel32.dll", SetLastError = true)] + [DllImport("kernel32.dll")] public static extern bool FreeConsole(); [DllImport("kernel32.dll")] @@ -22,7 +22,7 @@ public class Native [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lParam); - [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll", CharSet = CharSet.Unicode)] @@ -37,7 +37,7 @@ public class Native [DllImport("user32.dll")] public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu); - [DllImport("user32.dll", SetLastError = true)] + [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); [DllImport("user32.dll", EntryPoint = "GetWindowLong")] @@ -78,7 +78,7 @@ public class Native Bottom = bottom; } - public Rectangle ToRectangle() { return Rectangle.FromLTRB(Left, Top, Right, Bottom); } + public Rectangle ToRectangle() => Rectangle.FromLTRB(Left, Top, Right, Bottom); public Size Size => new Size(Right - Left, Bottom - Top); public int Width => Right - Left; public int Height => Bottom - Top; diff --git a/mpv.net/WPF/AboutWindow.xaml.cs b/mpv.net/WPF/AboutWindow.xaml.cs index d60093f..61920a3 100644 --- a/mpv.net/WPF/AboutWindow.xaml.cs +++ b/mpv.net/WPF/AboutWindow.xaml.cs @@ -10,7 +10,7 @@ namespace mpvnet { InitializeComponent(); Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion} ({File.GetLastWriteTime(System.Windows.Forms.Application.ExecutablePath).ToShortDateString()})"; - mpvVersion.Text = $"{mp.get_property_string("mpv-version")} ({File.GetLastWriteTime(PathHelp.StartupPath + "mpv-1.dll").ToShortDateString()})"; + mpvVersion.Text = $"{mp.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})"; } protected override void OnPreviewKeyDown(KeyEventArgs e) => Close(); diff --git a/mpv.net/WPF/EverythingWindow.xaml.cs b/mpv.net/WPF/EverythingWindow.xaml.cs index ddcb54c..4661338 100644 --- a/mpv.net/WPF/EverythingWindow.xaml.cs +++ b/mpv.net/WPF/EverythingWindow.xaml.cs @@ -134,7 +134,6 @@ namespace mpvnet StringBuilder buf = new StringBuilder(bufsize); Everything_SetSearch(searchtext); Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH); - Everything_SetSort(EVERYTHING_SORT_SIZE_DESCENDING); Everything_Query(true); for (i = 0; i < Everything_GetNumResults(); i++) diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 585ba38..bffe8e5 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -148,7 +148,7 @@ namespace mpvnet get { if (_ConfigFolder == null) { - string portableFolder = PathHelp.StartupPath + "portable_config\\"; + string portableFolder = Folder.Startup + "portable_config\\"; _ConfigFolder = portableFolder; if (!Directory.Exists(_ConfigFolder)) @@ -189,7 +189,7 @@ namespace mpvnet } } - if (PathHelp.StartupPath == _ConfigFolder) + if (Folder.Startup == _ConfigFolder) { Msg.ShowError("Startup folder and config folder cannot be identical, using portable_config instead."); _ConfigFolder = portableFolder; @@ -236,9 +236,9 @@ namespace mpvnet public static void LoadMpvScripts() { - if (Directory.Exists(PathHelp.StartupPath + "Scripts")) + if (Directory.Exists(Folder.Startup + "Scripts")) { - string[] startupScripts = Directory.GetFiles(PathHelp.StartupPath + "Scripts"); + string[] startupScripts = Directory.GetFiles(Folder.Startup + "Scripts"); foreach (string path in startupScripts) if ((path.EndsWith(".lua") || path.EndsWith(".js")) && KnownScripts.Contains(Path.GetFileName(path))) @@ -250,9 +250,9 @@ namespace mpvnet public static void LoadScripts() { - if (Directory.Exists(PathHelp.StartupPath + "Scripts")) + if (Directory.Exists(Folder.Startup + "Scripts")) { - foreach (string scriptPath in Directory.GetFiles(PathHelp.StartupPath + "Scripts")) + foreach (string scriptPath in Directory.GetFiles(Folder.Startup + "Scripts")) { if (KnownScripts.Contains(Path.GetFileName(scriptPath))) { @@ -329,7 +329,10 @@ namespace mpvnet } VideoSizeAutoResetEvent.Set(); Task.Run(new Action(() => ReadMetaData())); - WriteHistory(get_property_string("path")); + string path = mp.get_property_string("path"); + if (path.Contains("://")) + path = mp.get_property_string("media-title"); + WriteHistory(path); FileLoaded?.Invoke(); break; case mpv_event_id.MPV_EVENT_TRACKS_CHANGED: @@ -750,12 +753,14 @@ namespace mpvnet static void WriteHistory(string path) { - if (!File.Exists(ConfigFolder + "history.txt") || !File.Exists(path)) return; + if (!File.Exists(ConfigFolder + "history.txt")) + return; + int totalMinutes = Convert.ToInt32((DateTime.Now - LastHistoryStartDateTime).TotalMinutes); - if (File.Exists(LastHistoryPath) && totalMinutes > 1) + if (PathHelp.GetBaseName(LastHistoryPath) != "" && totalMinutes > 1) File.AppendAllText(ConfigFolder + "history.txt", DateTime.Now.ToString().Substring(0, 16) + - " " + totalMinutes.ToString().PadLeft(3) + " " + Path.GetFileNameWithoutExtension(LastHistoryPath) + "\r\n"); + " " + totalMinutes.ToString().PadLeft(3) + " " + PathHelp.GetBaseName(LastHistoryPath) + "\r\n"); LastHistoryPath = path; LastHistoryStartDateTime = DateTime.Now;