Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
857926696c | ||
|
|
4451a6c185 | ||
|
|
ea6a71b7c3 | ||
|
|
625dddcfbb | ||
|
|
0cd769fc0c | ||
|
|
f5e0c92824 | ||
|
|
327a097bcf | ||
|
|
68626fa536 | ||
|
|
8935101058 | ||
|
|
6947c925b9 | ||
|
|
4562131078 | ||
|
|
21188f0942 | ||
|
|
1316559ebc | ||
|
|
cd576f9211 | ||
|
|
1bac8e8937 | ||
|
|
e6d0449f8f | ||
|
|
e0e40b7918 | ||
|
|
b59f16a425 | ||
|
|
46b110d93b | ||
|
|
7e8a654ada | ||
|
|
c2c33228a0 |
26
Changelog.md
26
Changelog.md
@@ -1,3 +1,29 @@
|
||||
### 5.4.2
|
||||
|
||||
- new: the [scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting#powershell) was improved
|
||||
- new: Toggle Shuffle has been added to the menu defaults
|
||||
- new: for URLs the media title is shown in the title bar and in the info command
|
||||
instead of displaying the URL, mpv.conf defaults were changed to use
|
||||
[protocol.https] osd-playing-msg = '${media-title}'
|
||||
|
||||
- fix: on the very first start volume was set to 0 and mute was set to yes
|
||||
- fix: there was a sound when closed from taskbar
|
||||
- fix: the log feature was not working
|
||||
- fix: clipboard monitoring removed because it was causing to many issues
|
||||
- fix: restore resulted in collapsed window when maximized = yes was used
|
||||
|
||||
- update: libmpv shinchiro 2019-10-06
|
||||
- update: youtube-dl 2019-10-01
|
||||
|
||||
### 5.4.1.1
|
||||
|
||||
- a issue with the taskbar-progress feature was fixed
|
||||
- improved PowerShell scrip host
|
||||
|
||||
### 5.4.1
|
||||
|
||||
- fix ArgumentOutOfRangeException
|
||||
|
||||
### 5.4
|
||||
|
||||
- added taskbar-progress implementation
|
||||
|
||||
@@ -133,7 +133,7 @@ It's also possible to change the default application using the Open With feature
|
||||
|
||||
In order to play videos from sites such as YouTube the Chrome Extension [Play with mpv](https://chrome.google.com/webstore/detail/play-with-mpv/hahklcmnfgffdlchjigehabfbiigleji) can be used.
|
||||
|
||||
Due to Chrome Extensions not being able to start a app, another app that communicates with the extension is required, this app can be downloaded [here](http://www.mediafire.com/file/6tmwdjsfknhmsxy/play-with-mpvnet-server.7z/file). The extension works only when the app is running, to have the app always running a link can be created in the auto start folder located at:
|
||||
Due to Chrome Extensions not being able to start a app, another app that communicates with the extension is required, this app can be downloaded [here](http://www.mediafire.com/file/lezj8lwqt5zf75v/play-with-mpvnet-server.7z/file). The extension works only when the app is running, to have the app always running a link can be created in the auto start folder located at:
|
||||
|
||||
`C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup`
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace RatingExtension // the assembly name must end with 'Extension'
|
||||
string basename = Path.GetFileNameWithoutExtension(filepath);
|
||||
|
||||
for (int x = 0; x < 6; x++)
|
||||
if (basename.Contains(" (" + x.ToString() + "stars)"))
|
||||
basename = basename.Replace(" (" + x.ToString() + "stars)", "");
|
||||
if (basename.Contains(" (" + x + "stars)"))
|
||||
basename = basename.Replace(" (" + x + "stars)", "");
|
||||
|
||||
basename += $" ({rating}stars)";
|
||||
string newPath = Path.Combine(Path.GetDirectoryName(filepath), basename + Path.GetExtension(filepath));
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RatingExtension</RootNamespace>
|
||||
<AssemblyName>RatingExtension</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace ScriptingExtension // the file name of extensions must end with 'Exten
|
||||
if (Directory.Exists(mp.ConfigFolder + "scripts"))
|
||||
scriptFiles.AddRange(Directory.GetFiles(mp.ConfigFolder + "scripts", "*.cs"));
|
||||
|
||||
if (Directory.Exists(PathHelp.StartupPath + "scripts"))
|
||||
foreach (string path in Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs"))
|
||||
scriptFiles.AddRange(Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs"));
|
||||
if (Directory.Exists(Folder.Startup + "scripts"))
|
||||
foreach (string path in Directory.GetFiles(Folder.Startup + "scripts", "*.cs"))
|
||||
scriptFiles.AddRange(Directory.GetFiles(Folder.Startup + "scripts", "*.cs"));
|
||||
|
||||
if (scriptFiles.Count == 0) return;
|
||||
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ScriptingExtension</RootNamespace>
|
||||
<AssemblyName>ScriptingExtension</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,40 +1,17 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
using mpvnet;
|
||||
|
||||
class Script
|
||||
{
|
||||
MainForm Form;
|
||||
|
||||
bool WasPlaying;
|
||||
bool WasPaused;
|
||||
|
||||
public Script()
|
||||
{
|
||||
Form = MainForm.Instance;
|
||||
Form.Resize += Form_Resize;
|
||||
mp.Shutdown += Shutdown;
|
||||
}
|
||||
|
||||
private void Form_Resize(object sender, EventArgs e)
|
||||
private void Shutdown()
|
||||
{
|
||||
if (Form.WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
WasPlaying = mp.get_property_string("pause") == "no";
|
||||
|
||||
if (WasPlaying)
|
||||
{
|
||||
mp.command("set pause yes");
|
||||
WasPaused = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WasPaused)
|
||||
{
|
||||
mp.command("set pause no");
|
||||
WasPaused = false;
|
||||
}
|
||||
}
|
||||
foreach (string file in Directory.GetFiles(@"C:\Users\frank\Desktop\aaa"))
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
BIN
img/Terminal.png
BIN
img/Terminal.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 2.2 MiB |
@@ -3,6 +3,6 @@
|
||||
<configSections>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
|
||||
@@ -6,13 +6,12 @@ using System.Windows.Forms;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class App
|
||||
public static class App
|
||||
{
|
||||
public static string[] VideoTypes { get; } = "264 265 asf avc avi avs flv h264 h265 hevc m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm wmv y4m".Split(' ');
|
||||
public static string[] AudioTypes { get; } = "mp3 mp2 ac3 ogg opus flac wav w64 m4a dts dtsma dtshr dtshd eac3 thd thd+ac3 mka aac mpa".Split(' ');
|
||||
public static string[] ImageTypes { get; } = {"jpg", "bmp", "gif", "png"};
|
||||
public static string[] SubtitleTypes { get; } = { "srt", "ass", "idx", "sup", "ttxt", "ssa", "smi" };
|
||||
public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" };
|
||||
|
||||
public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
|
||||
public static string ConfPath { get => mp.ConfigFolder + "mpvnet.conf"; }
|
||||
@@ -34,7 +33,9 @@ namespace mpvnet
|
||||
public static int RecentCount { get; set; } = 15;
|
||||
|
||||
public static float MinimumAspectRatio { get; set; } = 1.3f;
|
||||
|
||||
|
||||
public static Extension Extension { get; set; }
|
||||
|
||||
public static bool IsDarkMode {
|
||||
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||
}
|
||||
@@ -71,8 +72,8 @@ namespace mpvnet
|
||||
{
|
||||
if (RememberVolume)
|
||||
{
|
||||
mp.set_property_int("volume", RegHelp.GetInt(App.RegPath, "Volume"));
|
||||
mp.set_property_string("mute", RegHelp.GetString(App.RegPath, "Mute"));
|
||||
mp.set_property_int("volume", RegHelp.GetInt(App.RegPath, "Volume", 70));
|
||||
mp.set_property_string("mute", RegHelp.GetString(App.RegPath, "Mute", "no"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +115,6 @@ namespace mpvnet
|
||||
case "debug-mode": DebugMode = value == "yes"; return true;
|
||||
case "dark-color": DarkColor = value.Trim('\'', '"'); return true;
|
||||
case "light-color": LightColor = value.Trim('\'', '"'); return true;
|
||||
case "url-whitelist": UrlWhitelist = value.Split(' ', ',', ';'); return true;
|
||||
case "remember-volume": RememberVolume = value == "yes"; return true;
|
||||
case "start-threshold": StartThreshold = value.Int(); return true;
|
||||
case "minimum-aspect-ratio": MinimumAspectRatio = value.Float(); return true;
|
||||
|
||||
@@ -38,6 +38,11 @@ namespace mpvnet
|
||||
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
|
||||
default: Msg.ShowError($"No command '{id}' found."); break;
|
||||
}
|
||||
|
||||
MainForm.Instance.BeginInvoke(new Action(() => {
|
||||
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
|
||||
Native.SendMessage(MainForm.Instance.Handle, m.Msg, m.WParam, m.LParam);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void InvokeOnMainThread(Action action) => MainForm.Instance.Invoke(action);
|
||||
@@ -116,6 +121,10 @@ namespace mpvnet
|
||||
string performer, title, album, genre, date, duration, text = "";
|
||||
long fileSize = 0;
|
||||
string path = mp.get_property_string("path");
|
||||
|
||||
if (path.Contains("://"))
|
||||
path = mp.get_property_string("media-title");
|
||||
|
||||
int width = mp.get_property_int("video-params/w");
|
||||
int height = mp.get_property_int("video-params/h");
|
||||
|
||||
@@ -176,7 +185,7 @@ namespace mpvnet
|
||||
$"{width} x {height}\n";
|
||||
|
||||
if (fileSize > 0)
|
||||
text += Convert.ToInt32(fileSize / 1024.0 / 1024.0).ToString() + " MB\n";
|
||||
text += Convert.ToInt32(fileSize / 1024.0 / 1024.0) + " MB\n";
|
||||
|
||||
text += $"{videoFormat}\n{audioCodec}";
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace mpvnet
|
||||
try
|
||||
{
|
||||
AggregateCatalog catalog = new AggregateCatalog();
|
||||
string dir = PathHelp.StartupPath + "Extensions";
|
||||
string dir = Folder.Startup + "Extensions";
|
||||
|
||||
if (Directory.Exists(dir))
|
||||
{
|
||||
|
||||
@@ -111,25 +111,25 @@ namespace mpvnet
|
||||
rk.SetValue(name, value);
|
||||
}
|
||||
|
||||
public static string GetString(string path, string name)
|
||||
public static string GetString(string path, string name, string defaultValue = "")
|
||||
{
|
||||
object val = GetObject(path, name);
|
||||
object val = GetObject(path, name, defaultValue);
|
||||
if (val == null || !(val is string)) return "";
|
||||
return val.ToString();
|
||||
}
|
||||
|
||||
public static int GetInt(string path, string name)
|
||||
public static int GetInt(string path, string name, int defaultValue = 0)
|
||||
{
|
||||
object val = GetObject(path, name);
|
||||
object val = GetObject(path, name, defaultValue);
|
||||
if (val == null || !(val is int)) return 0;
|
||||
return (int)val;
|
||||
}
|
||||
|
||||
public static object GetObject(string path, string name)
|
||||
public static object GetObject(string path, string name, object defaultValue = null)
|
||||
{
|
||||
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5)))
|
||||
if (rk != null)
|
||||
return rk.GetValue(name, "");
|
||||
return rk.GetValue(name, defaultValue);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
@@ -291,8 +291,34 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
public class Folder
|
||||
{
|
||||
public static string Startup { get; } = Application.StartupPath + "\\";
|
||||
}
|
||||
|
||||
public class PathHelp
|
||||
{
|
||||
public static string StartupPath { get; } = Application.StartupPath + "\\";
|
||||
public static string GetBaseName(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return "";
|
||||
|
||||
int index = value.IndexOf("/");
|
||||
|
||||
if (index > -1)
|
||||
value = value.Substring(index + 1);
|
||||
|
||||
index = value.IndexOf("\\");
|
||||
|
||||
if (index > -1)
|
||||
value = value.Substring(index + 1);
|
||||
|
||||
index = value.LastIndexOf(".");
|
||||
|
||||
if (index > -1)
|
||||
value = value.Substring(0, index);
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,9 @@ namespace mpvnet
|
||||
return;
|
||||
}
|
||||
|
||||
if (App.IsStartedFromTerminal) Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
||||
if (App.IsStartedFromTerminal)
|
||||
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
||||
|
||||
Application.Run(new MainForm());
|
||||
if (App.IsStartedFromTerminal) Native.FreeConsole();
|
||||
mutex.Dispose();
|
||||
|
||||
@@ -10,7 +10,7 @@ public class MediaInfo : IDisposable
|
||||
{
|
||||
if (!Loaded)
|
||||
{
|
||||
if (LoadLibrary("MediaInfo.dll") == IntPtr.Zero)
|
||||
if (Native.LoadLibrary("MediaInfo.dll") == IntPtr.Zero)
|
||||
throw new Exception("Failed to load MediaInfo.dll.");
|
||||
|
||||
Loaded = true;
|
||||
@@ -56,21 +56,27 @@ public class MediaInfo : IDisposable
|
||||
|
||||
~MediaInfo() { Dispose(); }
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
static extern IntPtr LoadLibrary(string path);
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr LoadLibrary(string path);
|
||||
|
||||
[DllImport("MediaInfo.dll")]
|
||||
static extern IntPtr MediaInfo_New();
|
||||
|
||||
[DllImport("MediaInfo.dll")]
|
||||
static extern void MediaInfo_Delete(IntPtr handle);
|
||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||
static extern int MediaInfo_Open(IntPtr handle, string path);
|
||||
|
||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||
static extern int MediaInfo_Open(IntPtr handle, string fileName);
|
||||
static extern IntPtr MediaInfo_Option(IntPtr handle, string optionString, string value);
|
||||
|
||||
[DllImport("MediaInfo.dll")]
|
||||
static extern IntPtr MediaInfo_Inform(IntPtr handle, int reserved);
|
||||
|
||||
[DllImport("MediaInfo.dll")]
|
||||
static extern int MediaInfo_Close(IntPtr handle);
|
||||
|
||||
[DllImport("MediaInfo.dll")]
|
||||
static extern void MediaInfo_Delete(IntPtr handle);
|
||||
|
||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||
static extern IntPtr MediaInfo_Get(IntPtr handle,
|
||||
MediaInfoStreamKind streamKind,
|
||||
|
||||
@@ -2,97 +2,94 @@
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace mpvnet
|
||||
public class Native
|
||||
{
|
||||
public class Native
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool AttachConsole(int dwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool FreeConsole();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr LoadLibrary(string path);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int RegisterWindowMessage(string id);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern void ReleaseCapture();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
|
||||
private static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
|
||||
private static extern IntPtr GetWindowLong64(IntPtr hWnd, int nIndex);
|
||||
|
||||
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool AttachConsole(int dwProcessId);
|
||||
if (IntPtr.Size == 8)
|
||||
return GetWindowLong64(hWnd, nIndex);
|
||||
else
|
||||
return GetWindowLong32(hWnd, nIndex);
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern bool FreeConsole();
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr LoadLibrary(string dllToLoad);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int RegisterWindowMessage(string id);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern void ReleaseCapture();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
|
||||
private static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
|
||||
private static extern IntPtr GetWindowLong64(IntPtr hWnd, int nIndex);
|
||||
|
||||
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
|
||||
public RECT(Rectangle r)
|
||||
{
|
||||
if (IntPtr.Size == 8)
|
||||
return GetWindowLong64(hWnd, nIndex);
|
||||
else
|
||||
return GetWindowLong32(hWnd, nIndex);
|
||||
Left = r.Left;
|
||||
Top = r.Top;
|
||||
Right = r.Right;
|
||||
Bottom = r.Bottom;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public RECT(Rectangle r)
|
||||
{
|
||||
Left = r.Left;
|
||||
Top = r.Top;
|
||||
Right = r.Right;
|
||||
Bottom = r.Bottom;
|
||||
}
|
||||
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
Left = left;
|
||||
Top = top;
|
||||
Right = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public Rectangle ToRectangle() { return Rectangle.FromLTRB(Left, Top, Right, Bottom); }
|
||||
public Size Size => new Size(Right - Left, Bottom - Top);
|
||||
public int Width => Right - Left;
|
||||
public int Height => Bottom - Top;
|
||||
Left = left;
|
||||
Top = top;
|
||||
Right = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct COPYDATASTRUCT
|
||||
{
|
||||
public IntPtr dwData;
|
||||
public int cbData;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string lpData;
|
||||
}
|
||||
public Rectangle ToRectangle() => Rectangle.FromLTRB(Left, Top, Right, Bottom);
|
||||
public Size Size => new Size(Right - Left, Bottom - Top);
|
||||
public int Width => Right - Left;
|
||||
public int Height => Bottom - Top;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct COPYDATASTRUCT
|
||||
{
|
||||
public IntPtr dwData;
|
||||
public int cbData;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string lpData;
|
||||
}
|
||||
}
|
||||
@@ -50,23 +50,23 @@ public class Msg
|
||||
td.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
|
||||
MessageBox.Show(e.GetType().Name + "\n\n" + e.Message + "\n\n" + e,
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowException(Exception e)
|
||||
public static void ShowException(Exception exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TaskDialog<string> td = new TaskDialog<string>())
|
||||
{
|
||||
td.MainInstruction = e.GetType().Name;
|
||||
td.Content = e.Message;
|
||||
td.MainInstruction = exception.GetType().Name;
|
||||
td.Content = exception.Message;
|
||||
td.MainIcon = MsgIcon.Error;
|
||||
td.ExpandedInformation = e.ToString();
|
||||
td.ExpandedInformation = exception.ToString();
|
||||
td.Footer = "[Copy Message](copymsg)";
|
||||
|
||||
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
||||
@@ -75,9 +75,9 @@ public class Msg
|
||||
td.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
|
||||
MessageBox.Show(e.GetType().Name + "\n\n" + e.Message + "\n\n" + e,
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@@ -144,9 +144,9 @@ public class Msg
|
||||
return td.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception e)
|
||||
{
|
||||
return (MsgResult)MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
|
||||
return (MsgResult)MessageBox.Show(e.GetType().Name + "\n\n" + e.Message + "\n\n" + e,
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@@ -235,6 +235,7 @@ public class TaskDialog<T> : TaskDialogNative, IDisposable
|
||||
|
||||
if (Path.GetFileName(lpszFileName.ToString().Replace(".vshost", "")) ==
|
||||
Path.GetFileName(Assembly.GetEntryAssembly().Location))
|
||||
|
||||
return foregroundWindow;
|
||||
|
||||
return IntPtr.Zero;
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("5.4.0.0")]
|
||||
[assembly: AssemblyFileVersion("5.4.0.0")]
|
||||
[assembly: AssemblyVersion("5.4.2.0")]
|
||||
[assembly: AssemblyFileVersion("5.4.2.0")]
|
||||
|
||||
58
mpv.net/Properties/Resources.Designer.cs
generated
58
mpv.net/Properties/Resources.Designer.cs
generated
@@ -62,19 +62,18 @@ namespace mpvnet.Properties {
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to
|
||||
/// # This file defines the input (keys and mouse) bindings of mpv and mpv.net
|
||||
/// # and it also defines the context menu of mpv.net. mpv.net has an input
|
||||
/// # editor and an config editor as alternative to editing conf text files.
|
||||
/// # The input and config editor can be found in mpv.net's context menu at:
|
||||
///
|
||||
/// # Settings > Show Config Editor
|
||||
/// # Settings > Show Input Editor
|
||||
///
|
||||
/// # The defaults of this file can be found at:
|
||||
/// # This file defines the key and mouse bindings and the context menu
|
||||
/// # of mpv.net. A input and config editor can be found in mpv.net's
|
||||
/// # context menu under 'Settings'. The defaults of this file can be found at:
|
||||
///
|
||||
/// # https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt
|
||||
///
|
||||
/// # th [rest of string was truncated]";.
|
||||
/// # The defaults of mpv can be found at:
|
||||
///
|
||||
/// # https://github.com/mpv-player/mpv/blob/master/etc/input.conf
|
||||
///
|
||||
/// # mpv.net's defaults of mpv.conf contain: 'input-default-bindings = no'
|
||||
/// # which disables mpv's [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string inputConf {
|
||||
get {
|
||||
@@ -83,21 +82,21 @@ namespace mpvnet.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to
|
||||
///# manual: https://mpv.io/manual/master/
|
||||
///
|
||||
///# defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt
|
||||
///
|
||||
/// Looks up a localized string similar to input-default-bindings = no
|
||||
///input-ar-delay = 500
|
||||
///input-ar-rate = 20
|
||||
///volume = 50
|
||||
///hwdec = yes
|
||||
///keep-open = yes
|
||||
///keep-open-pause = no
|
||||
///osd-playing-msg = '${filename}'
|
||||
///script-opts=osc-scalewindowed=1.5
|
||||
///screenshot-directory = '~~desktop/'
|
||||
///input-default-bindings = no
|
||||
///script-opts=osc-scalewindowed=1.5.
|
||||
///cscale = spline36
|
||||
///dscale = spline36
|
||||
///scale = spline36
|
||||
///hwdec = yes
|
||||
///
|
||||
///[protocol.https]
|
||||
///osd-playing-msg = '${media-title}'.
|
||||
/// </summary>
|
||||
internal static string mpvConf {
|
||||
get {
|
||||
@@ -143,24 +142,11 @@ namespace mpvnet.Properties {
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to [[settings]]
|
||||
///name = "dark-mode"
|
||||
///default = "always"
|
||||
///name = "process-instance"
|
||||
///default = "single"
|
||||
///filter = "General"
|
||||
///help = "Enables a dark theme. (mpv.net specific setting)"
|
||||
///options = [{ name = "always" },
|
||||
/// { name = "system" , help = "Available on Windows 10 or higher" },
|
||||
/// { name = "never" }]
|
||||
///
|
||||
///[[settings]]
|
||||
///name = "dark-color"
|
||||
///type = "color"
|
||||
///filter = "General"
|
||||
///help = "Theme color used in dark-mode. Leave empty to use OS theme. (mpv.net specific setting)"
|
||||
///
|
||||
///[[settings]]
|
||||
///name = "light-color"
|
||||
///type = "color"
|
||||
///filter = "General" [rest of string was truncated]";.
|
||||
///help = "Defines if more then one mpv.net process is allowed. (mpv.net specific setting)\n\nTip: Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This not only works on process startup but in all mpv.net features that open files and URLs."
|
||||
///options = [{ name = "multi", help = "Create a new process everytime the shell starts mpv.net [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string mpvNetConfToml {
|
||||
get {
|
||||
|
||||
2
mpv.net/Properties/Settings.Designer.cs
generated
2
mpv.net/Properties/Settings.Designer.cs
generated
@@ -12,7 +12,7 @@ namespace mpvnet.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
Ctrl+r script-message-to repl type "" #menu: Tools > Show REPL
|
||||
l ab-loop #menu: Tools > Set/clear A-B loop points
|
||||
L cycle-values loop-file "inf" "no" #menu: Tools > Toggle infinite file looping
|
||||
_ cycle shuffle #menu: Tools > Toggle Shuffle
|
||||
Ctrl+h cycle-values hwdec "auto" "no" #menu: Tools > Toggle Hardware Decoding
|
||||
_ script-message mpv.net show-setup-dialog #menu: Tools > OS Setup...
|
||||
|
||||
|
||||
@@ -9,4 +9,7 @@ screenshot-directory = '~~desktop/'
|
||||
cscale = spline36
|
||||
dscale = spline36
|
||||
scale = spline36
|
||||
hwdec = yes
|
||||
hwdec = yes
|
||||
|
||||
[protocol.https]
|
||||
osd-playing-msg = '${media-title}'
|
||||
@@ -1,15 +1,8 @@
|
||||
[[settings]]
|
||||
name = "url-whitelist"
|
||||
filter = "General"
|
||||
type = "string"
|
||||
help = "Whitelist setting to monitor the clipboard for URLs to play. (mpv.net specific setting)\n\nDefault: tube vimeo ard zdf\n\nHow to start mpv.net directly from Google Chrome is described in the manual:"
|
||||
url = "https://github.com/stax76/mpv.net/blob/master/Manual.md#chrome-extension"
|
||||
|
||||
[[settings]]
|
||||
name = "process-instance"
|
||||
default = "single"
|
||||
filter = "General"
|
||||
help = "Defines if more then one mpv.net process is allowed. (mpv.net specific setting)\n\nTip: Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This not only works on process startup but in all mpv.net features that open files."
|
||||
help = "Defines if more then one mpv.net process is allowed. (mpv.net specific setting)\n\nTip: Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This not only works on process startup but in all mpv.net features that open files and URLs."
|
||||
options = [{ name = "multi", help = "Create a new process everytime the shell starts mpv.net" },
|
||||
{ name = "single", help = "Force a single process everytime the shell starts mpv.net" },
|
||||
{ name = "queue", help = "Force a single process and add files to playlist" }]
|
||||
|
||||
@@ -3,13 +3,13 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Management.Automation.Runspaces;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Management.Automation;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class PowerShellScript
|
||||
{
|
||||
public static object Execute(string code, string[] parameters)
|
||||
public static void Execute(string filepath, params string[] parameters)
|
||||
{
|
||||
using (Runspace runspace = RunspaceFactory.CreateRunspace())
|
||||
{
|
||||
@@ -23,57 +23,53 @@ namespace mpvnet
|
||||
"Using namespace System\n" +
|
||||
"[System.Reflection.Assembly]::LoadWithPartialName(\"mpvnet\")\n");
|
||||
|
||||
pipeline.Commands.AddScript(code);
|
||||
pipeline.Commands.AddScript(File.ReadAllText(filepath));
|
||||
|
||||
if (parameters != null)
|
||||
foreach (var i in parameters)
|
||||
foreach (string i in parameters)
|
||||
pipeline.Commands[1].Parameters.Add(null, i);
|
||||
|
||||
try
|
||||
{
|
||||
var ret = pipeline.Invoke();
|
||||
if (ret.Count > 0) return ret[0];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Pipeline pipeline2 = runspace.CreatePipeline())
|
||||
{
|
||||
pipeline2.Commands.AddScript("$PSVersionTable.PSVersion.Major * 10 +" +
|
||||
"$PSVersionTable.PSVersion.Minor");
|
||||
PowerShellOutput output = new PowerShellOutput();
|
||||
output.ModuleName = Path.GetFileName(filepath);
|
||||
|
||||
if (Convert.ToInt32(pipeline2.Invoke()[0].ToString()) < 51)
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
Msg.ShowError("PowerShell Setup Problem\n\nEnsure you have at least PowerShell 5.1 installed.", e2.ToString());
|
||||
return null;
|
||||
}
|
||||
pipeline.Output.DataReady += output.Output_DataReady;
|
||||
pipeline.Error.DataReady += output.Error_DataReady;
|
||||
|
||||
runspace.SessionStateProxy.SetVariable("Output", output);
|
||||
|
||||
try {
|
||||
pipeline.Invoke();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
Msg.ShowError("PowerShell Exception", e.Message + "\n\n" +
|
||||
e.ErrorRecord.ScriptStackTrace.Replace(" <ScriptBlock>, <No file>", "") +
|
||||
"\n\n" + Path.GetFileName(filepath));
|
||||
}
|
||||
catch (Exception e) {
|
||||
Msg.ShowException(e);
|
||||
}
|
||||
|
||||
pipeline.Output.DataReady -= output.Output_DataReady;
|
||||
pipeline.Error.DataReady -= output.Error_DataReady;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Init(string filePath)
|
||||
public static void Init(string filepath)
|
||||
{
|
||||
foreach (var eventInfo in typeof(mp).GetEvents())
|
||||
{
|
||||
if (eventInfo.Name.ToLower() ==
|
||||
Path.GetFileNameWithoutExtension(filePath).ToLower().Replace("-", ""))
|
||||
Path.GetFileNameWithoutExtension(filepath).ToLower().Replace("-", ""))
|
||||
{
|
||||
PowerShellEventObject eventObject = new PowerShellEventObject();
|
||||
MethodInfo mi;
|
||||
eventObject.FilePath = filePath;
|
||||
eventObject.Filepath = filepath;
|
||||
|
||||
if (eventInfo.EventHandlerType == typeof(Action))
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.Invoke));
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<EndFileEventMode>))
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeEndFileEventMode));
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeEndFile));
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<string[]>))
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeStrings));
|
||||
else
|
||||
@@ -86,7 +82,33 @@ namespace mpvnet
|
||||
return;
|
||||
}
|
||||
}
|
||||
Task.Run(() => PowerShellScript.Execute(File.ReadAllText(filePath), null));
|
||||
Execute(filepath);
|
||||
}
|
||||
|
||||
class PowerShellOutput
|
||||
{
|
||||
public string ModuleName { get; set; }
|
||||
|
||||
public bool WriteStandard { get; set; } = true;
|
||||
public bool WriteError { get; set; } = true;
|
||||
|
||||
public void Output_DataReady(object sender, EventArgs e)
|
||||
{
|
||||
if (!WriteStandard) return;
|
||||
var output = sender as PipelineReader<PSObject>;
|
||||
while (output.Count > 0)
|
||||
Console.WriteLine("[" + ModuleName + "] " + output.Read().ToString());
|
||||
}
|
||||
|
||||
public void Error_DataReady(object sender, EventArgs e)
|
||||
{
|
||||
if (!WriteError) return;
|
||||
var output = sender as PipelineReader<Object>;
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
while (output.Count > 0)
|
||||
Console.WriteLine("[" + ModuleName + "] " + output.Read().ToString());
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,18 +116,10 @@ namespace mpvnet
|
||||
{
|
||||
public EventInfo EventInfo { get; set; }
|
||||
public Delegate Delegate { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
public string Filepath { get; set; }
|
||||
|
||||
public void Invoke() => Task.Run(() => PowerShellScript.Execute(File.ReadAllText(FilePath), null));
|
||||
|
||||
public void InvokeEndFileEventMode(EndFileEventMode arg)
|
||||
{
|
||||
Task.Run(() => PowerShellScript.Execute(File.ReadAllText(FilePath), new [] { arg.ToString() }));
|
||||
}
|
||||
|
||||
public void InvokeStrings(string[] args)
|
||||
{
|
||||
Task.Run(() => PowerShellScript.Execute(File.ReadAllText(FilePath), args));
|
||||
}
|
||||
public void Invoke() => PowerShellScript.Execute(Filepath);
|
||||
public void InvokeEndFile(EndFileEventMode arg) => PowerShellScript.Execute(Filepath, arg.ToString());
|
||||
public void InvokeStrings(string[] args) => PowerShellScript.Execute(Filepath, args);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
using Microsoft.Scripting;
|
||||
@@ -15,7 +16,7 @@ namespace mpvnet
|
||||
ScriptEngine engine;
|
||||
ScriptScope scope;
|
||||
|
||||
public PythonScript(string code)
|
||||
public PythonScript(string scriptPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -26,14 +27,14 @@ namespace mpvnet
|
||||
engine.Execute("clr.AddReference(\"mpvnet\")", scope);
|
||||
engine.Execute("import mpvnet", scope);
|
||||
engine.Execute("from mpvnet import *", scope);
|
||||
engine.Execute(code, scope);
|
||||
engine.Execute(File.ReadAllText(scriptPath), scope);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is SyntaxErrorException e)
|
||||
Msg.ShowError($"{e.Line}, {e.Column}: " + ex.Message);
|
||||
Msg.ShowError(e.GetType().Name,$"{e.Line}, {e.Column}: " + e.Message + "\n\n" + Path.GetFileName(scriptPath));
|
||||
else
|
||||
Msg.ShowException(ex);
|
||||
Msg.ShowError(ex.GetType().Name, ex.Message + "\n\n" + Path.GetFileName(scriptPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mpvnet
|
||||
{
|
||||
InitializeComponent();
|
||||
Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion} ({File.GetLastWriteTime(System.Windows.Forms.Application.ExecutablePath).ToShortDateString()})";
|
||||
mpvVersion.Text = $"{mp.get_property_string("mpv-version")} ({File.GetLastWriteTime(PathHelp.StartupPath + "mpv-1.dll").ToShortDateString()})";
|
||||
mpvVersion.Text = $"{mp.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})";
|
||||
}
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();
|
||||
|
||||
@@ -200,8 +200,7 @@ namespace mpvnet
|
||||
|
||||
private void FilterListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count > 0)
|
||||
SearchControl.Text = e.AddedItems[0].ToString() + ":";
|
||||
if (e.AddedItems.Count > 0) SearchControl.Text = e.AddedItems[0] + ":";
|
||||
}
|
||||
|
||||
private void OpenSettingsTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
|
||||
@@ -134,7 +134,6 @@ namespace mpvnet
|
||||
StringBuilder buf = new StringBuilder(bufsize);
|
||||
Everything_SetSearch(searchtext);
|
||||
Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH);
|
||||
Everything_SetSort(EVERYTHING_SORT_SIZE_DESCENDING);
|
||||
Everything_Query(true);
|
||||
|
||||
for (i = 0; i < Everything_GetNumResults(); i++)
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace mpvnet
|
||||
} catch {}
|
||||
|
||||
for (int i = 0; i < 13; i++)
|
||||
if ("D" + i.ToString() == text)
|
||||
if ("D" + i == text)
|
||||
text = text.Substring(1);
|
||||
|
||||
switch (e.KeyCode)
|
||||
@@ -59,7 +59,7 @@ namespace mpvnet
|
||||
case WF.Keys.NumPad7:
|
||||
case WF.Keys.NumPad8:
|
||||
case WF.Keys.NumPad9:
|
||||
text = "KP" + e.KeyCode.ToString()[6].ToString(); break;
|
||||
text = "KP" + e.KeyCode.ToString()[6]; break;
|
||||
case WF.Keys.Space:
|
||||
text = "Space"; break;
|
||||
case WF.Keys.Enter:
|
||||
|
||||
@@ -49,7 +49,8 @@ namespace mpvnet
|
||||
mp.observe_property_string("vid", PropChangeVid);
|
||||
mp.observe_property_int("edition", PropChangeEdition);
|
||||
|
||||
if (mp.GPUAPI != "vulkan") mp.ProcessCommandLine(false);
|
||||
if (mp.GPUAPI != "vulkan")
|
||||
mp.ProcessCommandLine(false);
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += (sender, e) => Msg.ShowError(e.ExceptionObject.ToString());
|
||||
Application.ThreadException += (sender, e) => Msg.ShowException(e.Exception);
|
||||
@@ -68,11 +69,18 @@ namespace mpvnet
|
||||
ContextMenu.Opened += ContextMenu_Opened;
|
||||
ContextMenu.Opening += ContextMenu_Opening;
|
||||
|
||||
if (mp.Screen == -1) mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
|
||||
if (mp.Screen == -1)
|
||||
mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
|
||||
|
||||
int targetIndex = mp.Screen;
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
if (targetIndex < 0) targetIndex = 0;
|
||||
if (targetIndex > screens.Length - 1) targetIndex = screens.Length - 1;
|
||||
|
||||
if (targetIndex < 0)
|
||||
targetIndex = 0;
|
||||
|
||||
if (targetIndex > screens.Length - 1)
|
||||
targetIndex = screens.Length - 1;
|
||||
|
||||
Screen screen = screens[Array.IndexOf(screens, screens[targetIndex])];
|
||||
Rectangle target = screen.Bounds;
|
||||
Left = target.X + (target.Width - Width) / 2;
|
||||
@@ -87,7 +95,8 @@ namespace mpvnet
|
||||
Top = posY - Height / 2;
|
||||
}
|
||||
|
||||
if (App.Maximized) WindowState = FormWindowState.Maximized;
|
||||
if (App.Maximized)
|
||||
WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -205,8 +214,10 @@ namespace mpvnet
|
||||
if (recent != null)
|
||||
{
|
||||
recent.DropDownItems.Clear();
|
||||
|
||||
foreach (string path in RecentFiles)
|
||||
MenuItem.Add(recent.DropDownItems, path, () => mp.Load(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control)));
|
||||
|
||||
recent.DropDownItems.Add(new ToolStripSeparator());
|
||||
MenuItem mi = new MenuItem("Clear List");
|
||||
mi.Action = () => RecentFiles.Clear();
|
||||
@@ -381,15 +392,16 @@ namespace mpvnet
|
||||
|
||||
BeginInvoke(new Action(() => {
|
||||
if (path.Contains("://"))
|
||||
Text = path + " - mpv.net " + Application.ProductVersion;
|
||||
Text = mp.get_property_string("media-title") + " - mpv.net " + Application.ProductVersion;
|
||||
else if (path.Contains(":\\") || path.StartsWith("\\\\"))
|
||||
Text = path.FileName() + " - mpv.net " + Application.ProductVersion;
|
||||
else
|
||||
Text = "mpv.net " + Application.ProductVersion;
|
||||
|
||||
ProgressTimer.Interval = (int)(mp.Duration.TotalMilliseconds / 99);
|
||||
if (ProgressTimer.Interval < 100) ProgressTimer.Interval = 100;
|
||||
if (ProgressTimer.Interval > 999) ProgressTimer.Interval = 999;
|
||||
int interval = (int)(mp.Duration.TotalMilliseconds / 100);
|
||||
if (interval < 100) interval = 100;
|
||||
if (interval > 1000) interval = 1000;
|
||||
ProgressTimer.Interval = interval;
|
||||
UpdateProgressBar();
|
||||
}));
|
||||
|
||||
@@ -408,7 +420,7 @@ namespace mpvnet
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
//Debug.WriteLine(m);
|
||||
Debug.WriteLine(m);
|
||||
|
||||
switch (m.Msg)
|
||||
{
|
||||
@@ -444,24 +456,31 @@ namespace mpvnet
|
||||
}
|
||||
break;
|
||||
case 0x02E0: // WM_DPICHANGED
|
||||
if (!WasShown) break;
|
||||
if (!WasShown)
|
||||
break;
|
||||
var r2 = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0);
|
||||
break;
|
||||
case 0x112: // WM_SYSCOMMAND
|
||||
if (m.WParam.ToInt32() == 0xf120) // SC_RESTORE
|
||||
SetFormPosAndSize();
|
||||
break;
|
||||
case 0x0214: // WM_SIZING
|
||||
var rc = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
||||
var r = rc;
|
||||
NativeHelp.SubtractWindowBorders(Handle, ref r);
|
||||
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
|
||||
Size s = mp.VideoSize;
|
||||
if (s == Size.Empty) s = new Size(16, 9);
|
||||
if (s == Size.Empty)
|
||||
s = new Size(16, 9);
|
||||
float aspect = s.Width / (float)s.Height;
|
||||
int d_w = Convert.ToInt32(c_h * aspect - c_w);
|
||||
int d_h = Convert.ToInt32(c_w / aspect - c_h);
|
||||
int[] d_corners = { d_w, d_h, -d_w, -d_h };
|
||||
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
|
||||
int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
|
||||
if (corner >= 0) corners[corner] -= d_corners[corner];
|
||||
if (corner >= 0)
|
||||
corners[corner] -= d_corners[corner];
|
||||
Marshal.StructureToPtr<Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
|
||||
m.Result = new IntPtr(1);
|
||||
return;
|
||||
@@ -486,7 +505,7 @@ namespace mpvnet
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.Msg == TaskbarButtonCreatedMessage)
|
||||
if (m.Msg == TaskbarButtonCreatedMessage && mp.TaskbarProgress)
|
||||
{
|
||||
Taskbar = new Taskbar(Handle);
|
||||
ProgressTimer.Start();
|
||||
@@ -543,7 +562,7 @@ namespace mpvnet
|
||||
|
||||
void PropChangePause(bool enabled)
|
||||
{
|
||||
if (Taskbar != null)
|
||||
if (Taskbar != null && mp.TaskbarProgress)
|
||||
{
|
||||
if (enabled)
|
||||
Taskbar.SetState(TaskbarStates.Paused);
|
||||
@@ -570,25 +589,18 @@ namespace mpvnet
|
||||
ContextMenuStrip = ContextMenu;
|
||||
WPF.WPF.Init();
|
||||
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
||||
CheckClipboardForURL();
|
||||
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
|
||||
WasShown = true;
|
||||
Task.Run(() => mp.LoadScripts());
|
||||
Task.Run(() => mp.Extension = new Extension());
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
{
|
||||
base.OnActivated(e);
|
||||
CheckClipboardForURL();
|
||||
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
|
||||
Native.SendMessage(Handle, m.Msg, m.WParam, m.LParam);
|
||||
mp.LoadScripts();
|
||||
Task.Run(() => App.Extension = new Extension());
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
if (mp.IsLogoVisible) mp.ShowLogo();
|
||||
|
||||
if (mp.IsLogoVisible)
|
||||
mp.ShowLogo();
|
||||
}
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
@@ -648,23 +660,5 @@ namespace mpvnet
|
||||
base.OnLostFocus(e);
|
||||
CursorHelp.Show();
|
||||
}
|
||||
|
||||
void CheckClipboardForURL()
|
||||
{
|
||||
string clipboard = Clipboard.GetText();
|
||||
|
||||
foreach (string url in App.UrlWhitelist)
|
||||
{
|
||||
if (clipboard.Contains("://") && !clipboard.Contains("\n") &&
|
||||
!clipboard.Contains(" ") && clipboard.Contains(url.ToLower().Trim()) &&
|
||||
RegHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible)
|
||||
{
|
||||
RegHelp.SetObject(App.RegPath, "LastURL", clipboard);
|
||||
|
||||
if (Msg.ShowQuestion("Play URL?", clipboard) == MsgResult.OK)
|
||||
mp.Load(new[] { clipboard }, true, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using System.Linq;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using Microsoft.Win32;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>mpvnet</RootNamespace>
|
||||
<AssemblyName>mpvnet</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
|
||||
@@ -16,7 +16,7 @@ using System.Windows.Forms;
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
using static mpvnet.libmpv;
|
||||
using static mpvnet.Native;
|
||||
using static Native;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -63,7 +63,6 @@ namespace mpvnet
|
||||
public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
|
||||
public static IntPtr Handle { get; set; }
|
||||
public static IntPtr WindowHandle { get; set; }
|
||||
public static Extension Extension { get; set; }
|
||||
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
|
||||
public static Size VideoSize { get; set; }
|
||||
public static TimeSpan Duration;
|
||||
@@ -149,7 +148,7 @@ namespace mpvnet
|
||||
get {
|
||||
if (_ConfigFolder == null)
|
||||
{
|
||||
string portableFolder = PathHelp.StartupPath + "portable_config\\";
|
||||
string portableFolder = Folder.Startup + "portable_config\\";
|
||||
_ConfigFolder = portableFolder;
|
||||
|
||||
if (!Directory.Exists(_ConfigFolder))
|
||||
@@ -190,7 +189,7 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
if (PathHelp.StartupPath == _ConfigFolder)
|
||||
if (Folder.Startup == _ConfigFolder)
|
||||
{
|
||||
Msg.ShowError("Startup folder and config folder cannot be identical, using portable_config instead.");
|
||||
_ConfigFolder = portableFolder;
|
||||
@@ -237,9 +236,9 @@ namespace mpvnet
|
||||
|
||||
public static void LoadMpvScripts()
|
||||
{
|
||||
if (Directory.Exists(PathHelp.StartupPath + "Scripts"))
|
||||
if (Directory.Exists(Folder.Startup + "Scripts"))
|
||||
{
|
||||
string[] startupScripts = Directory.GetFiles(PathHelp.StartupPath + "Scripts");
|
||||
string[] startupScripts = Directory.GetFiles(Folder.Startup + "Scripts");
|
||||
|
||||
foreach (string path in startupScripts)
|
||||
if ((path.EndsWith(".lua") || path.EndsWith(".js")) && KnownScripts.Contains(Path.GetFileName(path)))
|
||||
@@ -251,28 +250,28 @@ namespace mpvnet
|
||||
|
||||
public static void LoadScripts()
|
||||
{
|
||||
if (Directory.Exists(PathHelp.StartupPath + "Scripts"))
|
||||
if (Directory.Exists(Folder.Startup + "Scripts"))
|
||||
{
|
||||
foreach (string path in Directory.GetFiles(PathHelp.StartupPath + "Scripts"))
|
||||
foreach (string scriptPath in Directory.GetFiles(Folder.Startup + "Scripts"))
|
||||
{
|
||||
if (KnownScripts.Contains(Path.GetFileName(path)))
|
||||
if (KnownScripts.Contains(Path.GetFileName(scriptPath)))
|
||||
{
|
||||
if (path.EndsWith(".py"))
|
||||
PythonScripts.Add(new PythonScript(File.ReadAllText(path)));
|
||||
else if (path.EndsWith(".ps1"))
|
||||
PowerShellScript.Init(path);
|
||||
if (scriptPath.EndsWith(".py"))
|
||||
Task.Run(() => PythonScripts.Add(new PythonScript(scriptPath)));
|
||||
else if (scriptPath.EndsWith(".ps1"))
|
||||
Task.Run(() => PowerShellScript.Init(scriptPath));
|
||||
}
|
||||
else
|
||||
Msg.ShowError("Failed to load script", path + "\n\nOnly scripts that ship with mpv.net are allowed in <startup>\\scripts\n\nUser scripts have to use <config folder>\\scripts\n\nNever copy or install a new mpv.net version over a old mpv.net version.");
|
||||
Msg.ShowError("Failed to load script", scriptPath + "\n\nOnly scripts that ship with mpv.net are allowed in <startup>\\scripts\n\nUser scripts have to use <config folder>\\scripts\n\nNever copy or install a new mpv.net version over a old mpv.net version.");
|
||||
}
|
||||
}
|
||||
|
||||
if (Directory.Exists(ConfigFolder + "scripts"))
|
||||
foreach (string scriptPath in Directory.GetFiles(ConfigFolder + "scripts"))
|
||||
if (scriptPath.EndsWith(".py"))
|
||||
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
|
||||
if (scriptPath.EndsWith(".py"))
|
||||
Task.Run(() => PythonScripts.Add(new PythonScript(scriptPath)));
|
||||
else if (scriptPath.EndsWith(".ps1"))
|
||||
PowerShellScript.Init(scriptPath);
|
||||
Task.Run(() => PowerShellScript.Init(scriptPath));
|
||||
}
|
||||
|
||||
public static void EventLoop()
|
||||
@@ -330,7 +329,10 @@ namespace mpvnet
|
||||
}
|
||||
VideoSizeAutoResetEvent.Set();
|
||||
Task.Run(new Action(() => ReadMetaData()));
|
||||
WriteHistory(get_property_string("path"));
|
||||
string path = mp.get_property_string("path");
|
||||
if (path.Contains("://"))
|
||||
path = mp.get_property_string("media-title");
|
||||
WriteHistory(path);
|
||||
FileLoaded?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
|
||||
@@ -607,9 +609,12 @@ namespace mpvnet
|
||||
}
|
||||
else if (!preInit && !preInitProperties.Contains(left))
|
||||
{
|
||||
mp.ProcessProperty(left, right);
|
||||
if (!App.ProcessProperty(left, right))
|
||||
set_property_string(left, right, true);
|
||||
if (!PrintCommandLineArgument(arg))
|
||||
{
|
||||
mp.ProcessProperty(left, right);
|
||||
if (!App.ProcessProperty(left, right))
|
||||
set_property_string(left, right, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -629,7 +634,6 @@ namespace mpvnet
|
||||
i.Contains(":\\") || i.StartsWith("\\\\") || File.Exists(i)))
|
||||
{
|
||||
files.Add(i);
|
||||
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,6 +647,20 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
static bool PrintCommandLineArgument(string argument)
|
||||
{
|
||||
switch (argument)
|
||||
{
|
||||
case "--list-properties=yes":
|
||||
var list = get_property_string("property-list").Split(',').ToList();
|
||||
list.Sort();
|
||||
Console.WriteLine(string.Join("\r\n", list.ToArray()));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static DateTime LastLoad;
|
||||
|
||||
public static void Load(string[] files, bool loadFolder, bool append)
|
||||
@@ -735,12 +753,14 @@ namespace mpvnet
|
||||
|
||||
static void WriteHistory(string path)
|
||||
{
|
||||
if (!File.Exists(ConfigFolder + "history.txt") || !File.Exists(path)) return;
|
||||
if (!File.Exists(ConfigFolder + "history.txt"))
|
||||
return;
|
||||
|
||||
int totalMinutes = Convert.ToInt32((DateTime.Now - LastHistoryStartDateTime).TotalMinutes);
|
||||
|
||||
if (File.Exists(LastHistoryPath) && totalMinutes > 1)
|
||||
if (PathHelp.GetBaseName(LastHistoryPath) != "" && totalMinutes > 1)
|
||||
File.AppendAllText(ConfigFolder + "history.txt", DateTime.Now.ToString().Substring(0, 16) +
|
||||
" " + totalMinutes.ToString().PadLeft(3) + " " + Path.GetFileNameWithoutExtension(LastHistoryPath) + "\r\n");
|
||||
" " + totalMinutes.ToString().PadLeft(3) + " " + PathHelp.GetBaseName(LastHistoryPath) + "\r\n");
|
||||
|
||||
LastHistoryPath = path;
|
||||
LastHistoryStartDateTime = DateTime.Now;
|
||||
|
||||
Reference in New Issue
Block a user