diff --git a/docs/Changelog.md b/docs/Changelog.md index 5095034..dfd40ce 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -11,7 +11,8 @@ - mpv.net specific commands, the command palette, auto-play property and various other things are documented in the manual. - The action used for the right mouse button can be configured. -- Workaround not reproducible logo drawing crash. +- Workaround not reproducible logo drawing crash. +- Info command shows the length. - MediaInfo 22.03 diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 8450ad6..2993443 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -173,9 +173,6 @@ namespace mpvnet if (path.Contains("://")) path = Core.GetPropertyString("media-title"); - int width = Core.GetPropertyInt("video-params/w"); - int height = Core.GetPropertyInt("video-params/h"); - if (File.Exists(path)) { fileSize = new FileInfo(path).Length; @@ -223,12 +220,13 @@ namespace mpvnet string videoFormat = Core.GetPropertyString("video-format").ToUpper(); string audioCodec = Core.GetPropertyString("audio-codec-name").ToUpper(); - - text = path.FileName() + $"\n{width} x {height}\n"; - - if (fileSize > 0) - text += Convert.ToInt32(fileSize / 1024.0 / 1024.0) + " MB\n"; - + int width = Core.GetPropertyInt("video-params/w"); + int height = Core.GetPropertyInt("video-params/h"); + TimeSpan len = TimeSpan.FromSeconds(Core.GetPropertyDouble("duration")); + text = path.FileName() + "\n"; + text += FormatTime(len.TotalMinutes) + ":" + FormatTime(len.Seconds) + "\n"; + if (fileSize > 0) text += Convert.ToInt32(fileSize / 1024.0 / 1024.0) + " MB\n"; + text += $"{width} x {height}\n"; text += $"{videoFormat}\n{audioCodec}"; Core.CommandV("show-text", text, "5000"); @@ -239,6 +237,8 @@ namespace mpvnet } } + static string FormatTime(double value) => ((int)value).ToString("00"); + public static void ShowProgress() { TimeSpan position = TimeSpan.FromSeconds(Core.GetPropertyDouble("time-pos")); @@ -250,8 +250,6 @@ namespace mpvnet FormatTime(duration.Seconds); Core.CommandV("show-text", text, "5000"); - - string FormatTime(double value) => ((int)value).ToString("00"); } public static void OpenFromClipboard() => App.InvokeOnMainThread(() =>