diff --git a/CSScriptAddon/CSScriptAddon.vbproj b/CSScriptAddon/CSScriptAddon.vbproj
index a79dee0..7f5a970 100644
--- a/CSScriptAddon/CSScriptAddon.vbproj
+++ b/CSScriptAddon/CSScriptAddon.vbproj
@@ -55,6 +55,7 @@
False
..\mpvnet\bin\Debug\mpvnet.exe
+ True
@@ -66,6 +67,7 @@
..\vbnet\bin\Debug\vbnet.dll
+ True
diff --git a/RatingAddon/Rating.csproj b/RatingAddon/Rating.csproj
index 2f41cc9..739fcc5 100644
--- a/RatingAddon/Rating.csproj
+++ b/RatingAddon/Rating.csproj
@@ -69,6 +69,7 @@
..\mpvnet\bin\Debug\mpvnet.exe
+ True
diff --git a/Scripts/seek-show-position.js b/Scripts/seek-show-position.js
new file mode 100644
index 0000000..76dd735
--- /dev/null
+++ b/Scripts/seek-show-position.js
@@ -0,0 +1,31 @@
+// when seeking displays position and
+// duration like so: 00:00 / 120:00
+// this is different from MPC which
+// uses 00:00:00 / 02:00:00
+
+function add_zero(val)
+{
+ val = Math.round(val);
+ return val > 9 ? "" + val : "0" + val;
+}
+
+function format(val)
+{
+ var sec = Math.round(val);
+
+ if (sec < 0)
+ sec = 0;
+
+ pos_min_floor = Math.floor(sec / 60);
+ sec_rest = sec - pos_min_floor * 60;
+ return add_zero(pos_min_floor) + ":" + add_zero(sec_rest);
+}
+
+function on_seek(_)
+{
+ mp.commandv("show-text",
+ format(mp.get_property_number("time-pos")) + " / " +
+ format(mp.get_property_number("duration")));
+}
+
+mp.register_event("seek", on_seek);
\ No newline at end of file
diff --git a/mpvnet/Command.cs b/mpvnet/Command.cs
index 902f3fc..fcf0421 100644
--- a/mpvnet/Command.cs
+++ b/mpvnet/Command.cs
@@ -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)
+ {
+ }
+ }
}
}
\ No newline at end of file
diff --git a/mpvnet/MainForm.cs b/mpvnet/MainForm.cs
index db2f123..9740ad0 100644
--- a/mpvnet/MainForm.cs
+++ b/mpvnet/MainForm.cs
@@ -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)
{
diff --git a/mpvnet/Resources/input_conf.txt b/mpvnet/Resources/input_conf.txt
index 9b72de1..28ca324 100644
--- a/mpvnet/Resources/input_conf.txt
+++ b/mpvnet/Resources/input_conf.txt
@@ -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
\ No newline at end of file
diff --git a/mpvnet/mpv.cs b/mpvnet/mpv.cs
index 866ea75..118e3a3 100644
--- a/mpvnet/mpv.cs
+++ b/mpvnet/mpv.cs
@@ -49,7 +49,7 @@ namespace mpvnet
public static IntPtr MpvWindowHandle;
public static Addon Addon;
public static List> BoolPropChangeActions = new List>();
- 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();
diff --git a/release_mpvnet.ps1 b/release_mpvnet.ps1
new file mode 100644
index 0000000..790ea76
--- /dev/null
+++ b/release_mpvnet.ps1
@@ -0,0 +1,8 @@
+using namespace System.Diagnostics
+$exePath = "D:\Projekte\VS\CS\mpvnet\mpvnet\bin\Debug\mpvnet.exe"
+$version = [FileVersionInfo]::GetVersionInfo($exePath).FileVersion
+$targetDir = "C:\Users\Frank\Desktop\mpv-net-" + $version
+Copy-Item D:\Projekte\VS\CS\mpvnet\mpvnet\bin\Debug $targetDir -recurse
+$addonDir = $targetDir + "\Addons"
+remove-item $addonDir -Recurse -Include *vbnet.pdb, *mpvnet.exe, *mpvnet.exe.config, *mpvnet.pdb, *vbnet.dll
+D:\Projekte\VS\VB\util\bin\util.exe -pack $targetDir
\ No newline at end of file
diff --git a/vbnet/MediaInfo.vb b/vbnet/MediaInfo.vb
new file mode 100644
index 0000000..adb57ba
--- /dev/null
+++ b/vbnet/MediaInfo.vb
@@ -0,0 +1,93 @@
+Imports System.Runtime.InteropServices
+
+Public Class MediaInfo
+ Implements IDisposable
+
+ Private Handle As IntPtr
+ Shared Loaded As Boolean
+
+ Sub New(sourcepath As String)
+ If Not Loaded Then
+ If LoadLibrary("MediaInfo.dll") = IntPtr.Zero Then Throw New Exception("Failed to load MediaInfo.dll.")
+ Loaded = True
+ End If
+
+ Handle = MediaInfo_New()
+ MediaInfo_Open(Handle, sourcepath)
+ End Sub
+
+ Public Function GetInfo(streamKind As StreamKind, parameter As String) As String
+ Return Marshal.PtrToStringUni(MediaInfo_Get(Handle, streamKind, 0, parameter, InfoKind.Text, InfoKind.Name))
+ End Function
+
+#Region "IDisposable"
+
+ Private Disposed As Boolean
+
+ Sub Dispose() Implements IDisposable.Dispose
+ If Not Disposed Then
+ Disposed = True
+ MediaInfo_Close(Handle)
+ MediaInfo_Delete(Handle)
+ End If
+ End Sub
+
+ Protected Overrides Sub Finalize()
+ Dispose()
+ End Sub
+
+#End Region
+
+#Region "native"
+
+
+ Private Shared Function LoadLibrary(path As String) As IntPtr
+ End Function
+
+
+ Private Shared Function MediaInfo_New() As IntPtr
+ End Function
+
+
+ Private Shared Sub MediaInfo_Delete(Handle As IntPtr)
+ End Sub
+
+
+ Private Shared Function MediaInfo_Open(Handle As IntPtr, FileName As String) As Integer
+ End Function
+
+
+ Private Shared Function MediaInfo_Close(Handle As IntPtr) As Integer
+ End Function
+
+
+ Private Shared Function MediaInfo_Get(Handle As IntPtr,
+ StreamKind As StreamKind,
+ StreamNumber As Integer, Parameter As String,
+ KindOfInfo As InfoKind,
+ KindOfSearch As InfoKind) As IntPtr
+ End Function
+
+#End Region
+
+End Class
+
+Public Enum StreamKind
+ General
+ Video
+ Audio
+ Text
+ Chapters
+ Image
+End Enum
+
+Public Enum InfoKind
+ Name
+ Text
+ Measure
+ Options
+ NameText
+ MeasureText
+ Info
+ HowTo
+End Enum
\ No newline at end of file
diff --git a/vbnet/vbnet.vbproj b/vbnet/vbnet.vbproj
index 614c034..ff99d80 100644
--- a/vbnet/vbnet.vbproj
+++ b/vbnet/vbnet.vbproj
@@ -75,6 +75,7 @@
+
Component