Compare commits
29 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 | ||
|
|
0a28f13d51 | ||
|
|
9f3a1da931 | ||
|
|
05874ad6be | ||
|
|
078e8046bd | ||
|
|
b07901485e | ||
|
|
a37cbef8a8 | ||
|
|
8debcc171c | ||
|
|
e230f0f474 |
34
Changelog.md
34
Changelog.md
@@ -1,3 +1,37 @@
|
||||
### 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
|
||||
- added new setting to start with maximized window
|
||||
- long file paths work now even if not enabled by the OS
|
||||
- fixed history being written even when history file wasn't created prior
|
||||
- libmpv updated to shinchiro 2019-08-31
|
||||
|
||||
### 5.3
|
||||
|
||||
- added new feature: Open > Open DVD/Blu-ray Drive/Folder...
|
||||
|
||||
@@ -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`
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ Table of contents
|
||||
- Screenshot feature with many options
|
||||
- File history feature to log time and filename
|
||||
- A-B loop feature
|
||||
- watch later feature to save the position
|
||||
- Watch later feature to save the position
|
||||
- [Manual](#manual)
|
||||
|
||||
### Screenshots
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 628 KiB |
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 webm wmv y4m".Split(' ');
|
||||
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"; }
|
||||
@@ -23,6 +22,7 @@ namespace mpvnet
|
||||
|
||||
public static bool RememberHeight { get; set; } = true;
|
||||
public static bool RememberPosition { get; set; }
|
||||
public static bool Maximized { get; set; }
|
||||
public static bool DebugMode { get; set; }
|
||||
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
|
||||
public static bool RememberVolume { get; set; } = true;
|
||||
@@ -33,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";
|
||||
}
|
||||
@@ -70,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"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,13 +108,13 @@ namespace mpvnet
|
||||
switch (name)
|
||||
{
|
||||
case "remember-position": RememberPosition = value == "yes"; return true;
|
||||
case "maximized": Maximized = value == "yes"; return true;
|
||||
case "start-size": RememberHeight = value == "previous"; return true;
|
||||
case "process-instance": ProcessInstance = value; return true;
|
||||
case "dark-mode": DarkMode = value; return true;
|
||||
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);
|
||||
@@ -98,14 +103,15 @@ namespace mpvnet
|
||||
|
||||
public static void ShowHistory()
|
||||
{
|
||||
var fp = mp.ConfigFolder + "history.txt";
|
||||
|
||||
if (File.Exists(fp))
|
||||
Process.Start(fp);
|
||||
if (File.Exists(mp.ConfigFolder + "history.txt"))
|
||||
Process.Start(mp.ConfigFolder + "history.txt");
|
||||
else
|
||||
{
|
||||
if (Msg.ShowQuestion("Create history.txt file in config folder?",
|
||||
"mpv.net will write the date, time and filename of opened files to it.") == MsgResult.OK)
|
||||
File.WriteAllText(fp, "");
|
||||
|
||||
File.WriteAllText(mp.ConfigFolder + "history.txt", "");
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowInfo()
|
||||
@@ -115,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");
|
||||
|
||||
@@ -175,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace mpvnet
|
||||
files.Add(App.ProcessInstance);
|
||||
|
||||
foreach (string arg in args)
|
||||
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || File.Exists(arg)))
|
||||
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || arg.Contains(":\\") || arg.StartsWith("\\\\")))
|
||||
files.Add(arg);
|
||||
|
||||
Process[] procs = Process.GetProcessesByName("mpvnet");
|
||||
@@ -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,94 +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")]
|
||||
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;
|
||||
|
||||
53
mpv.net/Native/Taskbar.cs
Normal file
53
mpv.net/Native/Taskbar.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class Taskbar
|
||||
{
|
||||
private ITaskbarList3 Instance = (ITaskbarList3)new TaskBarCommunication();
|
||||
|
||||
public IntPtr Handle { get; set; }
|
||||
|
||||
public Taskbar(IntPtr handle) => Handle = handle;
|
||||
|
||||
[ComImportAttribute]
|
||||
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[GuidAttribute("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")]
|
||||
private interface ITaskbarList3
|
||||
{
|
||||
// ITaskbarList
|
||||
[PreserveSig] void HrInit();
|
||||
[PreserveSig] void AddTab(IntPtr hwnd);
|
||||
[PreserveSig] void DeleteTab(IntPtr hwnd);
|
||||
[PreserveSig] void ActivateTab(IntPtr hwnd);
|
||||
[PreserveSig] void SetActiveAlt(IntPtr hwnd);
|
||||
// ITaskbarList2
|
||||
[PreserveSig] void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
|
||||
// ITaskbarList3
|
||||
[PreserveSig] void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);
|
||||
[PreserveSig] void SetProgressState(IntPtr hwnd, TaskbarStates state);
|
||||
}
|
||||
|
||||
[ComImportAttribute]
|
||||
[ClassInterfaceAttribute(ClassInterfaceType.None)]
|
||||
[GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")]
|
||||
private class TaskBarCommunication { }
|
||||
|
||||
public void SetState(TaskbarStates taskbarState)
|
||||
{
|
||||
Instance.SetProgressState(Handle, taskbarState);
|
||||
}
|
||||
|
||||
public void SetValue(double progressValue, double progressMax)
|
||||
{
|
||||
Instance.SetProgressValue(Handle, (UInt64)progressValue, (UInt64)progressMax);
|
||||
}
|
||||
}
|
||||
|
||||
public enum TaskbarStates
|
||||
{
|
||||
NoProgress = 0,
|
||||
Indeterminate = 0x1,
|
||||
Normal = 0x2,
|
||||
Error = 0x4,
|
||||
Paused = 0x8
|
||||
}
|
||||
@@ -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.3.0.0")]
|
||||
[assembly: AssemblyFileVersion("5.3.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...
|
||||
|
||||
@@ -196,5 +197,4 @@
|
||||
Ctrl+Wheel_Up no-osd seek 7
|
||||
Ctrl+Wheel_Down no-osd seek -7
|
||||
MBTN_Left_DBL cycle fullscreen
|
||||
KP_Enter cycle fullscreen
|
||||
MBTN_Left ignore
|
||||
KP_Enter cycle fullscreen
|
||||
@@ -9,4 +9,7 @@ screenshot-directory = '~~desktop/'
|
||||
cscale = spline36
|
||||
dscale = spline36
|
||||
scale = spline36
|
||||
hwdec = yes
|
||||
hwdec = yes
|
||||
|
||||
[protocol.https]
|
||||
osd-playing-msg = '${media-title}'
|
||||
@@ -325,6 +325,14 @@ name = "screenshot-png-filter"
|
||||
filter = "Screen"
|
||||
help = "<0-5> Set the filter applied prior to PNG compression. 0 is none, 1 is 'sub', 2 is 'up', 3 is 'average', 4 is 'Paeth', and 5 is 'mixed'. This affects the level of compression that can be achieved. For most images, 'mixed' achieves the best compression ratio, hence it is the default."
|
||||
|
||||
[[settings]]
|
||||
name = "taskbar-progress"
|
||||
default = "yes"
|
||||
filter = "Playback"
|
||||
help = "Show progress in taskbar."
|
||||
options = [{ name = "yes" },
|
||||
{ name = "no" }]
|
||||
|
||||
[[settings]]
|
||||
name = "keep-open-pause"
|
||||
default = "yes"
|
||||
|
||||
@@ -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" }]
|
||||
@@ -45,6 +38,14 @@ help = "Save the window position on exit. (mpv.net specific setting)"
|
||||
options = [{ name = "yes" },
|
||||
{ name = "no" }]
|
||||
|
||||
[[settings]]
|
||||
name = "maximized"
|
||||
default = "no"
|
||||
filter = "Screen"
|
||||
help = "Start with a maximized window. (mpv.net specific setting)"
|
||||
options = [{ name = "yes" },
|
||||
{ name = "no" }]
|
||||
|
||||
[[settings]]
|
||||
name = "remember-volume"
|
||||
default = "yes"
|
||||
|
||||
@@ -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:
|
||||
|
||||
20
mpv.net/WinForms/MainForm.Designer.cs
generated
20
mpv.net/WinForms/MainForm.Designer.cs
generated
@@ -30,14 +30,19 @@
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
this.Timer = new System.Windows.Forms.Timer(this.components);
|
||||
this.CursorTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.ProgressTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Timer
|
||||
// CursorTimer
|
||||
//
|
||||
this.Timer.Enabled = true;
|
||||
this.Timer.Interval = 1000;
|
||||
this.Timer.Tick += new System.EventHandler(this.Timer_Tick);
|
||||
this.CursorTimer.Enabled = true;
|
||||
this.CursorTimer.Interval = 1000;
|
||||
this.CursorTimer.Tick += new System.EventHandler(this.CursorTimer_Tick);
|
||||
//
|
||||
// ProgressTimer
|
||||
//
|
||||
this.ProgressTimer.Tick += new System.EventHandler(this.ProgressTimer_Tick);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
@@ -45,7 +50,7 @@
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.ClientSize = new System.Drawing.Size(668, 345);
|
||||
this.ClientSize = new System.Drawing.Size(348, 0);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
@@ -57,6 +62,7 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Timer Timer;
|
||||
private System.Windows.Forms.Timer CursorTimer;
|
||||
private System.Windows.Forms.Timer ProgressTimer;
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,12 @@ namespace mpvnet
|
||||
{
|
||||
public static MainForm Instance { get; set; }
|
||||
public static IntPtr Hwnd { get; set; }
|
||||
|
||||
public new ContextMenuStripEx ContextMenu { get; set; }
|
||||
|
||||
Point LastCursorPosChanged;
|
||||
int LastCursorChangedTickCount;
|
||||
int TaskbarButtonCreatedMessage;
|
||||
bool WasShown;
|
||||
Taskbar Taskbar;
|
||||
List<string> RecentFiles;
|
||||
|
||||
public MainForm()
|
||||
@@ -38,7 +38,9 @@ namespace mpvnet
|
||||
mp.VideoSizeChanged += VideoSizeChanged;
|
||||
mp.FileLoaded += FileLoaded;
|
||||
mp.Idle += Idle;
|
||||
mp.Seek += () => UpdateProgressBar();
|
||||
|
||||
mp.observe_property_bool("pause", PropChangePause);
|
||||
mp.observe_property_bool("fullscreen", PropChangeFullscreen);
|
||||
mp.observe_property_bool("ontop", PropChangeOnTop);
|
||||
mp.observe_property_bool("border", PropChangeBorder);
|
||||
@@ -46,14 +48,16 @@ namespace mpvnet
|
||||
mp.observe_property_string("aid", PropChangeAid);
|
||||
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);
|
||||
Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
|
||||
Text = "mpv.net " + Application.ProductVersion;
|
||||
|
||||
TaskbarButtonCreatedMessage = Native.RegisterWindowMessage("TaskbarButtonCreated");
|
||||
|
||||
object recent = RegHelp.GetObject(App.RegPath, "Recent");
|
||||
|
||||
if (recent is string[] r)
|
||||
@@ -65,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;
|
||||
@@ -83,6 +94,9 @@ namespace mpvnet
|
||||
Left = posX - Width / 2;
|
||||
Top = posY - Height / 2;
|
||||
}
|
||||
|
||||
if (App.Maximized)
|
||||
WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -92,19 +106,22 @@ namespace mpvnet
|
||||
|
||||
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
||||
|
||||
void Idle() => BeginInvoke(new Action(() => Text = "mpv.net " + Application.ProductVersion));
|
||||
void Shutdown() => BeginInvoke(new Action(() => Close()));
|
||||
|
||||
void Idle()
|
||||
{
|
||||
BeginInvoke(new Action(() => Text = "mpv.net " + Application.ProductVersion));
|
||||
}
|
||||
|
||||
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
|
||||
|
||||
void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSize()));
|
||||
|
||||
void Shutdown() => BeginInvoke(new Action(() => Close()));
|
||||
|
||||
void PropChangeFullscreen(bool value) => BeginInvoke(new Action(() => CycleFullscreen(value)));
|
||||
|
||||
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
|
||||
|
||||
bool IsFullscreen => WindowState == FormWindowState.Maximized;
|
||||
bool IsFullscreen => WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None;
|
||||
|
||||
bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
|
||||
|
||||
@@ -197,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();
|
||||
@@ -228,6 +247,9 @@ namespace mpvnet
|
||||
|
||||
void SetFormPosAndSize()
|
||||
{
|
||||
if (WindowState == FormWindowState.Maximized)
|
||||
return;
|
||||
|
||||
if (mp.Fullscreen)
|
||||
{
|
||||
CycleFullscreen(true);
|
||||
@@ -320,7 +342,7 @@ namespace mpvnet
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WindowState == FormWindowState.Maximized)
|
||||
if (WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None)
|
||||
{
|
||||
WindowState = FormWindowState.Normal;
|
||||
|
||||
@@ -367,14 +389,22 @@ namespace mpvnet
|
||||
private void FileLoaded()
|
||||
{
|
||||
string path = mp.get_property_string("path");
|
||||
|
||||
BeginInvoke(new Action(() => {
|
||||
if (path.Contains("://"))
|
||||
Text = path + " - mpv.net " + Application.ProductVersion;
|
||||
else if (File.Exists(path))
|
||||
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;
|
||||
|
||||
int interval = (int)(mp.Duration.TotalMilliseconds / 100);
|
||||
if (interval < 100) interval = 100;
|
||||
if (interval > 1000) interval = 1000;
|
||||
ProgressTimer.Interval = interval;
|
||||
UpdateProgressBar();
|
||||
}));
|
||||
|
||||
if (RecentFiles.Contains(path)) RecentFiles.Remove(path);
|
||||
RecentFiles.Insert(0, path);
|
||||
while (RecentFiles.Count > App.RecentCount) RecentFiles.RemoveAt(App.RecentCount);
|
||||
@@ -390,7 +420,7 @@ namespace mpvnet
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
//Debug.WriteLine(m);
|
||||
Debug.WriteLine(m);
|
||||
|
||||
switch (m.Msg)
|
||||
{
|
||||
@@ -426,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;
|
||||
@@ -468,10 +505,16 @@ namespace mpvnet
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.Msg == TaskbarButtonCreatedMessage && mp.TaskbarProgress)
|
||||
{
|
||||
Taskbar = new Taskbar(Handle);
|
||||
ProgressTimer.Start();
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
void Timer_Tick(object sender, EventArgs e)
|
||||
void CursorTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
|
||||
{
|
||||
@@ -485,6 +528,14 @@ namespace mpvnet
|
||||
CursorHelp.Hide();
|
||||
}
|
||||
|
||||
private void ProgressTimer_Tick(object sender, EventArgs e) => UpdateProgressBar();
|
||||
|
||||
void UpdateProgressBar()
|
||||
{
|
||||
if (mp.TaskbarProgress && Taskbar != null)
|
||||
Taskbar.SetValue(mp.get_property_number("time-pos"), mp.Duration.TotalSeconds);
|
||||
}
|
||||
|
||||
void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
|
||||
|
||||
void PropChangeAid(string value) => mp.Aid = value;
|
||||
@@ -509,6 +560,17 @@ namespace mpvnet
|
||||
}));
|
||||
}
|
||||
|
||||
void PropChangePause(bool enabled)
|
||||
{
|
||||
if (Taskbar != null && mp.TaskbarProgress)
|
||||
{
|
||||
if (enabled)
|
||||
Taskbar.SetState(TaskbarStates.Paused);
|
||||
else
|
||||
Taskbar.SetState(TaskbarStates.Normal);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
@@ -527,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)
|
||||
@@ -605,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,9 +117,12 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="Timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<metadata name="CursorTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>30, 12</value>
|
||||
</metadata>
|
||||
<metadata name="ProgressTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>321, 12</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
||||
@@ -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 />
|
||||
@@ -153,6 +153,7 @@
|
||||
<Compile Include="DynamicGUI\Tommy.cs" />
|
||||
<Compile Include="Misc\ExtensionMethods.cs" />
|
||||
<Compile Include="Native\MediaInfo.cs" />
|
||||
<Compile Include="Native\Taskbar.cs" />
|
||||
<Compile Include="WinForms\Menu.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -61,12 +61,11 @@ namespace mpvnet
|
||||
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>();
|
||||
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
||||
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;
|
||||
public static AutoResetEvent ShutdownAutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||
public static AutoResetEvent VideoSizeAutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||
|
||||
@@ -81,7 +80,8 @@ namespace mpvnet
|
||||
public static bool IsQuitNeeded { set; get; } = true;
|
||||
public static bool Fullscreen { get; set; }
|
||||
public static bool Border { get; set; } = true;
|
||||
|
||||
public static bool TaskbarProgress { get; set; } = true;
|
||||
|
||||
public static int Screen { get; set; } = -1;
|
||||
public static int Edition { get; set; }
|
||||
|
||||
@@ -104,8 +104,8 @@ namespace mpvnet
|
||||
|
||||
set_property_string("wid", MainForm.Hwnd.ToString());
|
||||
set_property_string("osc", "yes");
|
||||
set_property_string("force-window", "yes");
|
||||
set_property_string("input-media-keys", "yes");
|
||||
set_property_string("force-window", "yes");
|
||||
set_property_string("config-dir", ConfigFolder);
|
||||
set_property_string("config", "yes");
|
||||
|
||||
@@ -136,6 +136,7 @@ namespace mpvnet
|
||||
case "fs":
|
||||
case "fullscreen": Fullscreen = value == "yes"; break;
|
||||
case "border": Border = value == "yes"; break;
|
||||
case "taskbar-progress": TaskbarProgress = value == "yes"; break;
|
||||
case "screen": Screen = Convert.ToInt32(value); break;
|
||||
case "gpu-api": GPUAPI = value; break;
|
||||
}
|
||||
@@ -147,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))
|
||||
@@ -188,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;
|
||||
@@ -235,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)))
|
||||
@@ -249,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()
|
||||
@@ -317,7 +318,7 @@ namespace mpvnet
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_FILE_LOADED:
|
||||
HideLogo();
|
||||
FileLoaded?.Invoke();
|
||||
Duration = TimeSpan.FromSeconds(get_property_number("duration"));
|
||||
Size vidSize = new Size(get_property_int("width"), get_property_int("height"));
|
||||
if (vidSize.Width == 0 || vidSize.Height == 0)
|
||||
vidSize = new Size(1, 1);
|
||||
@@ -328,7 +329,11 @@ 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:
|
||||
TracksChanged?.Invoke();
|
||||
@@ -416,11 +421,8 @@ namespace mpvnet
|
||||
|
||||
static void HideLogo()
|
||||
{
|
||||
if (IsLogoVisible)
|
||||
{
|
||||
commandv("overlay-remove", "0");
|
||||
IsLogoVisible = false;
|
||||
}
|
||||
command("overlay-remove 0");
|
||||
IsLogoVisible = false;
|
||||
}
|
||||
|
||||
static List<PythonEventObject> PythonEventObjects = new List<PythonEventObject>();
|
||||
@@ -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)
|
||||
@@ -625,10 +630,10 @@ namespace mpvnet
|
||||
|
||||
foreach (string i in args)
|
||||
{
|
||||
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") || File.Exists(i)))
|
||||
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") ||
|
||||
i.Contains(":\\") || i.StartsWith("\\\\") || File.Exists(i)))
|
||||
{
|
||||
files.Add(i);
|
||||
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,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)
|
||||
@@ -734,14 +753,14 @@ namespace mpvnet
|
||||
|
||||
static void WriteHistory(string path)
|
||||
{
|
||||
if (!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