Info command shows the length

This commit is contained in:
stax76
2022-04-02 11:40:40 +02:00
parent 8ed62df8e2
commit ce12eb61fd
2 changed files with 11 additions and 12 deletions

View File

@@ -11,7 +11,8 @@
- mpv.net specific commands, the command palette, auto-play property - mpv.net specific commands, the command palette, auto-play property
and various other things are documented in the manual. and various other things are documented in the manual.
- The action used for the right mouse button can be configured. - 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 - MediaInfo 22.03

View File

@@ -173,9 +173,6 @@ namespace mpvnet
if (path.Contains("://")) if (path.Contains("://"))
path = Core.GetPropertyString("media-title"); path = Core.GetPropertyString("media-title");
int width = Core.GetPropertyInt("video-params/w");
int height = Core.GetPropertyInt("video-params/h");
if (File.Exists(path)) if (File.Exists(path))
{ {
fileSize = new FileInfo(path).Length; fileSize = new FileInfo(path).Length;
@@ -223,12 +220,13 @@ namespace mpvnet
string videoFormat = Core.GetPropertyString("video-format").ToUpper(); string videoFormat = Core.GetPropertyString("video-format").ToUpper();
string audioCodec = Core.GetPropertyString("audio-codec-name").ToUpper(); string audioCodec = Core.GetPropertyString("audio-codec-name").ToUpper();
int width = Core.GetPropertyInt("video-params/w");
text = path.FileName() + $"\n{width} x {height}\n"; int height = Core.GetPropertyInt("video-params/h");
TimeSpan len = TimeSpan.FromSeconds(Core.GetPropertyDouble("duration"));
if (fileSize > 0) text = path.FileName() + "\n";
text += Convert.ToInt32(fileSize / 1024.0 / 1024.0) + " MB\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}"; text += $"{videoFormat}\n{audioCodec}";
Core.CommandV("show-text", text, "5000"); 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() public static void ShowProgress()
{ {
TimeSpan position = TimeSpan.FromSeconds(Core.GetPropertyDouble("time-pos")); TimeSpan position = TimeSpan.FromSeconds(Core.GetPropertyDouble("time-pos"));
@@ -250,8 +250,6 @@ namespace mpvnet
FormatTime(duration.Seconds); FormatTime(duration.Seconds);
Core.CommandV("show-text", text, "5000"); Core.CommandV("show-text", text, "5000");
string FormatTime(double value) => ((int)value).ToString("00");
} }
public static void OpenFromClipboard() => App.InvokeOnMainThread(() => public static void OpenFromClipboard() => App.InvokeOnMainThread(() =>