-
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
<Reference Include="mpvnet, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\mpvnet\bin\Debug\mpvnet.exe</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
@@ -66,6 +67,7 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="vbnet">
|
||||
<HintPath>..\vbnet\bin\Debug\vbnet.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="mpvnet">
|
||||
<HintPath>..\mpvnet\bin\Debug\mpvnet.exe</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
|
||||
31
Scripts/seek-show-position.js
Normal file
31
Scripts/seek-show-position.js
Normal file
@@ -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);
|
||||
@@ -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
|
||||
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();
|
||||
|
||||
8
release_mpvnet.ps1
Normal file
8
release_mpvnet.ps1
Normal file
@@ -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
|
||||
93
vbnet/MediaInfo.vb
Normal file
93
vbnet/MediaInfo.vb
Normal file
@@ -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"
|
||||
|
||||
<DllImport("kernel32.dll", CharSet:=CharSet.Unicode)>
|
||||
Private Shared Function LoadLibrary(path As String) As IntPtr
|
||||
End Function
|
||||
|
||||
<DllImport("MediaInfo.dll")>
|
||||
Private Shared Function MediaInfo_New() As IntPtr
|
||||
End Function
|
||||
|
||||
<DllImport("MediaInfo.dll")>
|
||||
Private Shared Sub MediaInfo_Delete(Handle As IntPtr)
|
||||
End Sub
|
||||
|
||||
<DllImport("MediaInfo.dll", CharSet:=CharSet.Unicode)>
|
||||
Private Shared Function MediaInfo_Open(Handle As IntPtr, FileName As String) As Integer
|
||||
End Function
|
||||
|
||||
<DllImport("MediaInfo.dll")>
|
||||
Private Shared Function MediaInfo_Close(Handle As IntPtr) As Integer
|
||||
End Function
|
||||
|
||||
<DllImport("MediaInfo.dll", CharSet:=CharSet.Unicode)>
|
||||
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
|
||||
@@ -75,6 +75,7 @@
|
||||
<Compile Include="Extensions.vb" />
|
||||
<Compile Include="HSLColor.vb" />
|
||||
<Compile Include="MainModule.vb" />
|
||||
<Compile Include="MediaInfo.vb" />
|
||||
<Compile Include="Menu.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user