Compare commits

...

3 Commits
1.1 ... 1.2

Author SHA1 Message Date
Frank Skare
3fd1285ad8 - 2019-03-17 20:56:10 +01:00
Frank Skare
91a67c29a7 - 2019-03-14 21:40:08 +01:00
Frank Skare
c8ce0b6dfc 1.1 2019-03-14 07:02:38 +01:00
6 changed files with 66 additions and 27 deletions

View File

@@ -9,8 +9,9 @@ mpv manual: https://mpv.io/manual/master/
### Features
- Customizable context menu defined in the same file as the keybindings
- Addons support for using .NET languages
- C# scripts implemented with CS-Script
- Addon API for .NET languages
- Python scripting implemented with IronPython
- C# scripting implemented with CS-Script
- mpv's OSC, IPC, Lua/JS, conf files and more
![](https://raw.githubusercontent.com/stax76/mpv.net/master/screenshot.png)
@@ -48,6 +49,39 @@ class Script
}
```
### Python Scripting
A simple Python script located at: C:\Users\user\AppData\Roaming\mpv\scripts
```
# when seeking displays position and
# duration like so: 70:00 / 80:00
# which is different from mpv which
# uses 01:10:00 / 01:20:00
import math
def seek():
mp.commandv('show-text',
format(mp.get_property_number("time-pos")) + " / " + format(mp.get_property_number("duration")))
def format(f):
sec = round(f)
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)
def add_zero(val):
val = round(val)
return "" + str(int(val)) if (val > 9) else "0" + str(int(val))
mp.register_event("seek", seek) # or use: mp.Seek += seek
```
### Changes
### 1.1

View File

@@ -52,7 +52,6 @@
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "mpv.net";
this.Load += new System.EventHandler(this.MainForm_Load);
this.ResumeLayout(false);
}

View File

@@ -4,7 +4,7 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Diagnostics;
using static mpvnet.StaticUsing;
namespace mpvnet
@@ -16,7 +16,7 @@ namespace mpvnet
private Point LastCursorPosChanged;
private int LastCursorChangedTickCount;
private bool IsCloseRequired = true;
private bool IsClosed;
public ContextMenuStripEx CMS;
@@ -93,7 +93,7 @@ namespace mpvnet
private string LastHistory;
private void mpv_PlaybackRestart()
private void mp_PlaybackRestart()
{
var fn = mp.GetStringProp("filename");
BeginInvoke(new Action(() => { Text = fn + " - mpv.net " + Application.ProductVersion; }));
@@ -121,14 +121,14 @@ namespace mpvnet
MsgError(e.ToString());
}
private void Mpv_VideoSizeChanged()
private void mp_VideoSizeChanged()
{
BeginInvoke(new Action(() => SetFormPosSize()));
}
private void Mpv_AfterShutdown()
private void mp_Shutdown()
{
if (IsCloseRequired)
if (!IsClosed)
Invoke(new Action(() => Close()));
}
@@ -137,7 +137,7 @@ namespace mpvnet
get => WindowState == FormWindowState.Maximized;
}
void MpvChangeFullscreen(bool value)
void mp_ChangeFullscreen(bool value)
{
BeginInvoke(new Action(() => ChangeFullscreen(value)));
}
@@ -263,13 +263,6 @@ namespace mpvnet
CursorHelp.Show();
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
IsCloseRequired = false;
mp.Command("quit");
}
bool IsMouseInOSC()
{
return PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
@@ -290,13 +283,27 @@ namespace mpvnet
}
}
private void MainForm_Load(object sender, EventArgs ea)
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
mp.Init();
mp.ObserveBoolProp("fullscreen", MpvChangeFullscreen);
mp.Shutdown += Mpv_AfterShutdown;
mp.VideoSizeChanged += Mpv_VideoSizeChanged;
mp.PlaybackRestart += mpv_PlaybackRestart;
mp.ObserveBoolProp("fullscreen", mp_ChangeFullscreen);
mp.Shutdown += mp_Shutdown;
mp.VideoSizeChanged += mp_VideoSizeChanged;
mp.PlaybackRestart += mp_PlaybackRestart;
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
IsClosed = true;
mp.Command("quit");
for (int i = 0; i < 99; i++)
{
if (mp.IsShutdownComplete) break;
Thread.Sleep(50);
}
}
}
}

View File

@@ -104,7 +104,7 @@
k script-message mpv.net show-keys #menu: K ; Settings > Show Keys
c script-message mpv.net open-config-folder #menu: C ; Settings > Open Config Folder
i show-progress ; script-message mpv.net show-info #menu: I ; Tools | Info
i script-message mpv.net show-info #menu: I ; Tools | Info
t script-binding stats/display-stats #menu: T ; Tools > Show Statistics
T script-binding stats/display-stats-toggle #menu: Shift+T ; Tools > Toggle Statistics
_ ignore #menu: _ ; Tools > -

View File

@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -61,6 +61,7 @@ namespace mpvnet
public static string InputConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\input.conf";
public static string mpvConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\mpv.conf";
public static List<PyScript> PyScripts { get; } = new List<PyScript>();
public static bool IsShutdownComplete { get; set; }
private static Dictionary<string, string> _mpvConv;
@@ -133,7 +134,6 @@ namespace mpvnet
{
IntPtr ptr = mpv_wait_event(MpvHandle, -1);
mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event));
//Debug.WriteLine(evt.event_id);
if (MpvWindowHandle == IntPtr.Zero)
MpvWindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null);
@@ -142,6 +142,7 @@ namespace mpvnet
{
case mpv_event_id.MPV_EVENT_SHUTDOWN:
Shutdown?.Invoke();
IsShutdownComplete = true;
return;
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
LogMessage?.Invoke();

View File

@@ -3,10 +3,8 @@ $exePath = $scriptDir + "\mpv.net\bin\Debug\mpvnet.exe"
$version = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath).FileVersion
$desktopDir = [Environment]::GetFolderPath("Desktop")
$targetDir = $desktopDir + "\mpv.net-" + $version
if (Test-Path $targetDir) { rd $targetDir -recurse }
Copy-Item $scriptDir\mpv.net\bin\Debug $targetDir -recurse
$addonDir = $targetDir + "\Addons"
Remove-Item $addonDir -Recurse -Include *mpvnet.exe, *mpvnet.exe.config, *mpvnet.pdb
$7zPath = "C:\Program Files\7-Zip\7z.exe"
$args = "a -t7z -mx9 $targetDir.7z -r $targetDir\*"
Start-Process -FilePath $7zPath -ArgumentList $args