-
This commit is contained in:
@@ -23,6 +23,8 @@ using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using vbnet;
|
||||
using System.Drawing;
|
||||
using static vbnet.UI.MainModule;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -99,5 +101,42 @@ namespace mpvnet
|
||||
|
||||
ProcessHelp.Start(OS.GetTextEditor(), '"' + filepath + '"');
|
||||
}
|
||||
|
||||
public static void show_info(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var fi = new FileInfo(mpv.GetStringProp("path"));
|
||||
|
||||
using (var mi = new MediaInfo(fi.FullName))
|
||||
{
|
||||
var w = mi.GetInfo(StreamKind.Video, "Width");
|
||||
var h = mi.GetInfo(StreamKind.Video, "Height");
|
||||
var pos = TimeSpan.FromSeconds(mpv.GetIntProp("time-pos"));
|
||||
var dur = TimeSpan.FromSeconds(mpv.GetIntProp("duration"));
|
||||
var br = Convert.ToInt32(mi.GetInfo(StreamKind.Video, "BitRate")) / 1000;
|
||||
var vf = mpv.GetStringProp("video-format").ToUpper();
|
||||
var fn = fi.Name;
|
||||
|
||||
if (fn.Length > 60)
|
||||
fn = fn.Insert(59, BR);
|
||||
|
||||
var info =
|
||||
FormatTime(pos.TotalMinutes) + ":" +
|
||||
FormatTime(pos.Seconds) + " / " +
|
||||
FormatTime(dur.TotalMinutes) + ":" +
|
||||
FormatTime(dur.Seconds) + "\n" +
|
||||
((int)(fi.Length / 1024 / 1024)).ToString() +
|
||||
$" MB - {w} x {h}\n{vf} - {br} Kbps" + "\n" + fn;
|
||||
|
||||
mpv.Command("show-text", info, "5000");
|
||||
|
||||
string FormatTime(double value) => ((int)(Math.Floor(value))).ToString("00");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using vbnet;
|
||||
@@ -48,6 +47,7 @@ namespace mpvnet
|
||||
{
|
||||
Application.ThreadException += Application_ThreadException;
|
||||
InitializeComponent();
|
||||
SetFormPosSize();
|
||||
Instance = this;
|
||||
Hwnd = Handle;
|
||||
mpv.Init();
|
||||
@@ -101,7 +101,7 @@ namespace mpvnet
|
||||
var menuItem = CMS.Add(path, () => {
|
||||
try
|
||||
{
|
||||
mpv.CommandString(cmd);
|
||||
mpv.CommandString(cmd, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
o script-message mpv.net open-files #menu: O; Open Files
|
||||
|
||||
Space pause #menu: Space ; Play/Pause
|
||||
Space cycle pause #menu: Space ; Play/Pause
|
||||
s stop #menu: S ; Stop
|
||||
|
||||
F11 playlist-prev #menu: F11 ; Navigate | Previous
|
||||
@@ -20,18 +20,18 @@ KP8 cycle sub #menu: Numpad 8 ; Cycle Subtitle
|
||||
- add volume -5 #menu: - ; Volume | Down
|
||||
Axis_Up add volume 5 # wheel up
|
||||
Axis_Down add volume -5 # wheel down
|
||||
_ _ #menu: _ ; Volume | -
|
||||
m mute #menu: M ; Volume | Mute
|
||||
_ ignore #menu: _ ; Volume | -
|
||||
m cycle mute #menu: M ; Volume | Mute
|
||||
|
||||
Alt++ add audio-delay 0.1 #menu: Alt++ ; Audio | Delay +0.1
|
||||
Alt+- add audio-delay -0.1 #menu: Alt+- ; Audio | Delay -0.1
|
||||
KP6 add audio-delay 0.100 #menu: Numpad 6 ; Audio | Delay +0.1
|
||||
KP9 add audio-delay -0.100 #menu: Numpad 9 ; Audio | Delay -0.1
|
||||
|
||||
Right seek 10 #menu: Right ; Seek | 10 sec forward
|
||||
Left seek -10 #menu: Left ; Seek | 10 sec backward
|
||||
_ _ #menu: _ ; Seek | -
|
||||
Right seek 5 #menu: Right ; Seek | 10 sec forward
|
||||
Left seek -5 #menu: Left ; Seek | 10 sec backward
|
||||
_ ignore #menu: _ ; Seek | -
|
||||
Up seek 60 #menu: Up ; Seek | 1 min forward
|
||||
Down seek -60 #menu: Down ; Seek | 1 min backward
|
||||
_ _ #menu: _ ; Seek | -
|
||||
_ ignore #menu: _ ; Seek | -
|
||||
Ctrl+Right seek 300 #menu: Ctrl+Right ; Seek | 5 min forward
|
||||
Ctrl+Left seek -300 #menu: Ctrl+Left ; Seek | 5 min backward
|
||||
|
||||
@@ -45,5 +45,6 @@ KP5 script-message rate-file 5 #menu: Numpad 5 ; Addons | Rating | 5stars
|
||||
p script-message mpv.net show-prefs #menu: P ; Preferences
|
||||
k script-message mpv.net show-keys #menu: K ; Keys
|
||||
|
||||
F8 script-message mpv.net open-config-folder #menu: _ ; Tools | Config Folder
|
||||
Esc quit #menu: Escape ; Exit
|
||||
i script-message mpv.net show-info #menu: I ; Tools | Info
|
||||
c script-message mpv.net open-config-folder #menu: _ ; Tools | Config Folder
|
||||
Esc quit #menu: Escape ; Exit
|
||||
@@ -49,7 +49,7 @@ namespace mpvnet
|
||||
public static IntPtr MpvWindowHandle;
|
||||
public static Addon Addon;
|
||||
public static List<Action<bool>> BoolPropChangeActions = new List<Action<bool>>();
|
||||
public static Size VideoSize;
|
||||
public static Size VideoSize = new Size(1920, 1080);
|
||||
public static string InputConfPath = Folder.AppDataRoaming + "mpv\\input.conf";
|
||||
public static StringPairList BindingList = new StringPairList();
|
||||
|
||||
@@ -154,14 +154,14 @@ namespace mpvnet
|
||||
Marshal.FreeHGlobal(mainPtr);
|
||||
}
|
||||
|
||||
public static void CommandString(string command)
|
||||
public static void CommandString(string command, bool throwException = true)
|
||||
{
|
||||
if (MpvHandle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
int err = mpv_command_string(MpvHandle, command);
|
||||
|
||||
if (err < 0)
|
||||
if (err < 0 && throwException)
|
||||
throw new Exception($"{(mpv_error)err}" + BR2 + command);
|
||||
}
|
||||
|
||||
@@ -187,12 +187,12 @@ namespace mpvnet
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int GetIntProp(string name)
|
||||
public static int GetIntProp(string name, bool throwException = true)
|
||||
{
|
||||
var lpBuffer = IntPtr.Zero;
|
||||
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref lpBuffer);
|
||||
|
||||
if (err < 0)
|
||||
if (err < 0 && throwException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
else
|
||||
return lpBuffer.ToInt32();
|
||||
|
||||
Reference in New Issue
Block a user