diff --git a/docs/Changelog.md b/docs/Changelog.md index cceee94..3ba3db2 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,4 +1,10 @@ +5.4.9.1 (2021-0?-??) +==================== + +- New media info command: Ctrl+m script-message mpv.net show-media-info #menu: View > Show Media Info + + 5.4.9.0 (2021-05-29) ==================== diff --git a/docs/Manual.md b/docs/Manual.md index 8b6bdd2..46d4bef 100644 --- a/docs/Manual.md +++ b/docs/Manual.md @@ -60,10 +60,14 @@ Download Installation ------------ -mpv.net requires the .NET Framework 4.8 and Windows 7 or 10 and a modern graphics card. +mpv.net requires the .NET Framework 4.8 and Windows 7 or higher and a modern graphics card. There is a setup exe and a portable zip file download. +An old version should be uninstalled before installing a new version, +it's generally not a good idea to install a new version on top of an old version, +the setup don't enforce it because it's not easy to implement. + For internet streaming youtube-dl must be downloaded and installed manually, meaning it must be located in the PATH environment variable or in the startup directory. diff --git a/src/Misc/App.cs b/src/Misc/App.cs index 220da57..5eeacf0 100644 --- a/src/Misc/App.cs +++ b/src/Misc/App.cs @@ -12,6 +12,8 @@ namespace mpvnet { public static class App { + public static List TempFiles { get; } = new List(); + public static string ConfPath { get => Core.ConfigFolder + "mpvnet.conf"; } public static string ProcessInstance { get; set; } = "single"; public static string DarkMode { get; set; } = "always"; @@ -164,6 +166,9 @@ namespace mpvnet Settings.Mute = Core.get_property_string("mute"); SettingsManager.Save(Settings); + + foreach (string file in TempFiles) + FileHelp.Delete(file); } static Dictionary _Conf; diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 3704857..ec9fbc6 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -8,15 +8,13 @@ using System.Windows.Forms; using System.Windows.Interop; using System.Windows; -using VB = Microsoft.VisualBasic; - using static mpvnet.Global; namespace mpvnet { public class Commands { - public static void Execute(string id, string[] args = null) + public static void Execute(string id, string[] args) { switch (id) { @@ -44,8 +42,9 @@ namespace mpvnet case "show-info": ShowInfo(); break; case "show-input-editor": ShowDialog(typeof(InputWindow)); break; case "show-keys": ShowTextWithEditor("input-key-list", Core.get_property_string("input-key-list").Replace(",", BR)); break; + case "show-media-info": ShowMediaInfo(args); break; case "show-media-search": ShowDialog(typeof(EverythingWindow)); break; - case "show-playlist": ShowPlaylist(); break; + case "show-playlist": ShowPlaylist(args); break; case "show-profiles": ShowTextWithEditor("profile-list", mpvHelp.GetProfiles()); break; case "show-properties": ShowProperties(); break; case "show-protocols": ShowTextWithEditor("protocol-list", mpvHelp.GetProtocols()); break; @@ -54,7 +53,7 @@ namespace mpvnet case "update-check": UpdateCheck.CheckOnline(true); break; case "window-scale": WindowScale(float.Parse(args[0], CultureInfo.InvariantCulture)); break; - default: Msg.ShowError($"No command '{id}' found."); break; + default: App.ShowError($"No command '{id}' found."); break; } } @@ -338,7 +337,8 @@ namespace mpvnet public static void ShowTextWithEditor(string name, string text) { - string file = Path.GetTempPath() + $"\\{name}.txt"; + string file = Path.Combine(Path.GetTempPath(), name + ".txt"); + App.TempFiles.Add(file); File.WriteAllText(file, BR + text.Trim() + BR); ProcessHelp.ShellExecute(file); } @@ -362,12 +362,12 @@ namespace mpvnet "}${osd-ass-cc/1}" + text + "\" " + duration); } - public static void ShowPlaylist(string[] args = null) + public static void ShowPlaylist(string[] args) { int duration = 5000; - if (args?.Length == 1) - duration = Convert.ToInt32(args[0]); + if (args.Length == 1 && int.TryParse(args[0], out int result)) + duration = result; var size = Core.get_property_number("osd-font-size"); Core.set_property_number("osd-font-size", 40); @@ -378,5 +378,21 @@ namespace mpvnet Core.set_property_number("osd-font-size", size); }); } + + public static void ShowMediaInfo(string[] args) + { + string path = Core.GetPropertyString("path"); + + if (File.Exists(path)) + { + using (MediaInfo mediaInfo = new MediaInfo(path)) + { + bool full = args.Contains("full"); + bool raw = args.Contains("raw"); + string text = mediaInfo.GetSummary(full, raw); + ShowTextWithEditor(Path.GetFileName(path), text); + } + } + } } } diff --git a/src/Misc/CorePlayer.cs b/src/Misc/CorePlayer.cs index 484a419..2f5e86c 100644 --- a/src/Misc/CorePlayer.cs +++ b/src/Misc/CorePlayer.cs @@ -762,6 +762,11 @@ namespace mpvnet HandleError(err, throwException, $"error setting property: {name} = {value}"); } + public string GetPropertyString(string name, bool throwException = false) + { + return get_property_string(name, throwException); + } + public string get_property_string(string name, bool throwException = false) { mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), diff --git a/src/Misc/Help.cs b/src/Misc/Help.cs index 054dbd2..e43bfa0 100644 --- a/src/Misc/Help.cs +++ b/src/Misc/Help.cs @@ -2,6 +2,7 @@ using System; using System.Diagnostics; using System.Drawing; +using System.IO; using System.Linq; using System.Windows.Forms; @@ -11,6 +12,19 @@ using static mpvnet.Global; namespace mpvnet { + public static class FileHelp + { + public static void Delete(string path) + { + try { + if (File.Exists(path)) + File.Delete(path); + } catch (Exception ex) { + Terminal.WriteError("Failed to delete file:" + BR + path + BR + ex.Message); + } + } + } + public static class ProcessHelp { public static void Execute(string file, string arguments = null) diff --git a/src/Native/MediaInfo.cs b/src/Native/MediaInfo.cs index 15673d3..860af80 100644 --- a/src/Native/MediaInfo.cs +++ b/src/Native/MediaInfo.cs @@ -41,6 +41,13 @@ public class MediaInfo : IDisposable stream, parameter, MediaInfoKind.Text, MediaInfoKind.Name)); } + public string GetSummary(bool complete, bool rawView) + { + MediaInfo_Option(Handle, "Language", rawView ? "raw" : ""); + MediaInfo_Option(Handle, "Complete", complete ? "1" : "0"); + return Marshal.PtrToStringUni(MediaInfo_Inform(Handle, 0)) ?? ""; + } + bool Disposed; public void Dispose() diff --git a/src/Resources/input.conf.txt b/src/Resources/input.conf.txt index c98d820..eb372e0 100644 --- a/src/Resources/input.conf.txt +++ b/src/Resources/input.conf.txt @@ -141,10 +141,10 @@ Alt+3 script-message mpv.net window-scale 3.0 #menu: View > Zoom > 300 % b cycle border #menu: View > Toggle Border i script-message mpv.net show-info #menu: View > File/Stream Info - t script-binding stats/display-stats #menu: View > Show Statistics - T script-binding stats/display-stats-toggle #menu: View > Toggle Statistics Del script-binding osc/visibility #menu: View > Toggle OSC Visibility Ctrl+r cycle-values video-rotate 90 180 270 0 #menu: View > Rotate Video + T script-binding stats/display-stats-toggle #menu: View > Toggle Statistics + t script-binding stats/display-stats #menu: View > Show Statistics _ script-message mpv.net show-audio-devices #menu: View > Show Audio Devices Shift+c script-message mpv.net show-commands #menu: View > Show Commands ` script-binding console/enable #menu: View > Show Console @@ -157,6 +157,7 @@ Shift+p script-message mpv.net show-properties #menu: View > Show Properties _ script-message mpv.net show-protocols #menu: View > Show Protocols F9 show-text ${track-list} 5000 #menu: View > Show Tracks + Ctrl+m script-message mpv.net show-media-info #menu: View > Show Media Info c script-message mpv.net show-conf-editor #menu: Settings > Show Config Editor Ctrl+i script-message mpv.net show-input-editor #menu: Settings > Show Input Editor diff --git a/src/Scripts/C-Sharp/rate-file.cs b/src/Scripts/C-Sharp/rate-file.cs index c0858d9..47ee256 100644 --- a/src/Scripts/C-Sharp/rate-file.cs +++ b/src/Scripts/C-Sharp/rate-file.cs @@ -77,8 +77,5 @@ class Script Dic[path] = rating; Core.commandv("show-text", "Rating: " + rating); } - else if (args[1] == "about") - MessageBox.Show("This extension writes a rating to the filename of rated videos when mpv.net shuts down.", - "Rating Extension"); } }