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
|
### 5.4
|
||||||
|
|
||||||
- added taskbar-progress implementation
|
- 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.
|
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`
|
`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);
|
string basename = Path.GetFileNameWithoutExtension(filepath);
|
||||||
|
|
||||||
for (int x = 0; x < 6; x++)
|
for (int x = 0; x < 6; x++)
|
||||||
if (basename.Contains(" (" + x.ToString() + "stars)"))
|
if (basename.Contains(" (" + x + "stars)"))
|
||||||
basename = basename.Replace(" (" + x.ToString() + "stars)", "");
|
basename = basename.Replace(" (" + x + "stars)", "");
|
||||||
|
|
||||||
basename += $" ({rating}stars)";
|
basename += $" ({rating}stars)";
|
||||||
string newPath = Path.Combine(Path.GetDirectoryName(filepath), basename + Path.GetExtension(filepath));
|
string newPath = Path.Combine(Path.GetDirectoryName(filepath), basename + Path.GetExtension(filepath));
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>RatingExtension</RootNamespace>
|
<RootNamespace>RatingExtension</RootNamespace>
|
||||||
<AssemblyName>RatingExtension</AssemblyName>
|
<AssemblyName>RatingExtension</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ namespace ScriptingExtension // the file name of extensions must end with 'Exten
|
|||||||
if (Directory.Exists(mp.ConfigFolder + "scripts"))
|
if (Directory.Exists(mp.ConfigFolder + "scripts"))
|
||||||
scriptFiles.AddRange(Directory.GetFiles(mp.ConfigFolder + "scripts", "*.cs"));
|
scriptFiles.AddRange(Directory.GetFiles(mp.ConfigFolder + "scripts", "*.cs"));
|
||||||
|
|
||||||
if (Directory.Exists(PathHelp.StartupPath + "scripts"))
|
if (Directory.Exists(Folder.Startup + "scripts"))
|
||||||
foreach (string path in Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs"))
|
foreach (string path in Directory.GetFiles(Folder.Startup + "scripts", "*.cs"))
|
||||||
scriptFiles.AddRange(Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs"));
|
scriptFiles.AddRange(Directory.GetFiles(Folder.Startup + "scripts", "*.cs"));
|
||||||
|
|
||||||
if (scriptFiles.Count == 0) return;
|
if (scriptFiles.Count == 0) return;
|
||||||
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
|
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>ScriptingExtension</RootNamespace>
|
<RootNamespace>ScriptingExtension</RootNamespace>
|
||||||
<AssemblyName>ScriptingExtension</AssemblyName>
|
<AssemblyName>ScriptingExtension</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -1,40 +1,17 @@
|
|||||||
using System;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
using mpvnet;
|
using mpvnet;
|
||||||
|
|
||||||
class Script
|
class Script
|
||||||
{
|
{
|
||||||
MainForm Form;
|
|
||||||
|
|
||||||
bool WasPlaying;
|
|
||||||
bool WasPaused;
|
|
||||||
|
|
||||||
public Script()
|
public Script()
|
||||||
{
|
{
|
||||||
Form = MainForm.Instance;
|
mp.Shutdown += Shutdown;
|
||||||
Form.Resize += Form_Resize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Form_Resize(object sender, EventArgs e)
|
private void Shutdown()
|
||||||
{
|
{
|
||||||
if (Form.WindowState == FormWindowState.Minimized)
|
foreach (string file in Directory.GetFiles(@"C:\Users\frank\Desktop\aaa"))
|
||||||
{
|
File.Delete(file);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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>
|
||||||
</configSections>
|
</configSections>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||||
</startup>
|
</startup>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -6,13 +6,12 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace mpvnet
|
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[] 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[] 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[] ImageTypes { get; } = {"jpg", "bmp", "gif", "png"};
|
||||||
public static string[] SubtitleTypes { get; } = { "srt", "ass", "idx", "sup", "ttxt", "ssa", "smi" };
|
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 RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
|
||||||
public static string ConfPath { get => mp.ConfigFolder + "mpvnet.conf"; }
|
public static string ConfPath { get => mp.ConfigFolder + "mpvnet.conf"; }
|
||||||
@@ -35,6 +34,8 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static float MinimumAspectRatio { get; set; } = 1.3f;
|
public static float MinimumAspectRatio { get; set; } = 1.3f;
|
||||||
|
|
||||||
|
public static Extension Extension { get; set; }
|
||||||
|
|
||||||
public static bool IsDarkMode {
|
public static bool IsDarkMode {
|
||||||
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||||
}
|
}
|
||||||
@@ -71,8 +72,8 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
if (RememberVolume)
|
if (RememberVolume)
|
||||||
{
|
{
|
||||||
mp.set_property_int("volume", RegHelp.GetInt(App.RegPath, "Volume"));
|
mp.set_property_int("volume", RegHelp.GetInt(App.RegPath, "Volume", 70));
|
||||||
mp.set_property_string("mute", RegHelp.GetString(App.RegPath, "Mute"));
|
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 "debug-mode": DebugMode = value == "yes"; return true;
|
||||||
case "dark-color": DarkColor = value.Trim('\'', '"'); return true;
|
case "dark-color": DarkColor = value.Trim('\'', '"'); return true;
|
||||||
case "light-color": LightColor = 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 "remember-volume": RememberVolume = value == "yes"; return true;
|
||||||
case "start-threshold": StartThreshold = value.Int(); return true;
|
case "start-threshold": StartThreshold = value.Int(); return true;
|
||||||
case "minimum-aspect-ratio": MinimumAspectRatio = value.Float(); 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
|
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
|
||||||
default: Msg.ShowError($"No command '{id}' found."); break;
|
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);
|
public static void InvokeOnMainThread(Action action) => MainForm.Instance.Invoke(action);
|
||||||
@@ -116,6 +121,10 @@ namespace mpvnet
|
|||||||
string performer, title, album, genre, date, duration, text = "";
|
string performer, title, album, genre, date, duration, text = "";
|
||||||
long fileSize = 0;
|
long fileSize = 0;
|
||||||
string path = mp.get_property_string("path");
|
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 width = mp.get_property_int("video-params/w");
|
||||||
int height = mp.get_property_int("video-params/h");
|
int height = mp.get_property_int("video-params/h");
|
||||||
|
|
||||||
@@ -176,7 +185,7 @@ namespace mpvnet
|
|||||||
$"{width} x {height}\n";
|
$"{width} x {height}\n";
|
||||||
|
|
||||||
if (fileSize > 0)
|
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}";
|
text += $"{videoFormat}\n{audioCodec}";
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace mpvnet
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
AggregateCatalog catalog = new AggregateCatalog();
|
AggregateCatalog catalog = new AggregateCatalog();
|
||||||
string dir = PathHelp.StartupPath + "Extensions";
|
string dir = Folder.Startup + "Extensions";
|
||||||
|
|
||||||
if (Directory.Exists(dir))
|
if (Directory.Exists(dir))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -111,25 +111,25 @@ namespace mpvnet
|
|||||||
rk.SetValue(name, value);
|
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 "";
|
if (val == null || !(val is string)) return "";
|
||||||
return val.ToString();
|
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;
|
if (val == null || !(val is int)) return 0;
|
||||||
return (int)val;
|
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)))
|
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5)))
|
||||||
if (rk != null)
|
if (rk != null)
|
||||||
return rk.GetValue(name, "");
|
return rk.GetValue(name, defaultValue);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -291,8 +291,34 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Folder
|
||||||
|
{
|
||||||
|
public static string Startup { get; } = Application.StartupPath + "\\";
|
||||||
|
}
|
||||||
|
|
||||||
public class PathHelp
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App.IsStartedFromTerminal) Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
if (App.IsStartedFromTerminal)
|
||||||
|
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
||||||
|
|
||||||
Application.Run(new MainForm());
|
Application.Run(new MainForm());
|
||||||
if (App.IsStartedFromTerminal) Native.FreeConsole();
|
if (App.IsStartedFromTerminal) Native.FreeConsole();
|
||||||
mutex.Dispose();
|
mutex.Dispose();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class MediaInfo : IDisposable
|
|||||||
{
|
{
|
||||||
if (!Loaded)
|
if (!Loaded)
|
||||||
{
|
{
|
||||||
if (LoadLibrary("MediaInfo.dll") == IntPtr.Zero)
|
if (Native.LoadLibrary("MediaInfo.dll") == IntPtr.Zero)
|
||||||
throw new Exception("Failed to load MediaInfo.dll.");
|
throw new Exception("Failed to load MediaInfo.dll.");
|
||||||
|
|
||||||
Loaded = true;
|
Loaded = true;
|
||||||
@@ -56,21 +56,27 @@ public class MediaInfo : IDisposable
|
|||||||
|
|
||||||
~MediaInfo() { Dispose(); }
|
~MediaInfo() { Dispose(); }
|
||||||
|
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
[DllImport("kernel32.dll")]
|
||||||
static extern IntPtr LoadLibrary(string path);
|
public static extern IntPtr LoadLibrary(string path);
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll")]
|
[DllImport("MediaInfo.dll")]
|
||||||
static extern IntPtr MediaInfo_New();
|
static extern IntPtr MediaInfo_New();
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll")]
|
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||||
static extern void MediaInfo_Delete(IntPtr handle);
|
static extern int MediaInfo_Open(IntPtr handle, string path);
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
[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")]
|
[DllImport("MediaInfo.dll")]
|
||||||
static extern int MediaInfo_Close(IntPtr handle);
|
static extern int MediaInfo_Close(IntPtr handle);
|
||||||
|
|
||||||
|
[DllImport("MediaInfo.dll")]
|
||||||
|
static extern void MediaInfo_Delete(IntPtr handle);
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||||
static extern IntPtr MediaInfo_Get(IntPtr handle,
|
static extern IntPtr MediaInfo_Get(IntPtr handle,
|
||||||
MediaInfoStreamKind streamKind,
|
MediaInfoStreamKind streamKind,
|
||||||
|
|||||||
@@ -2,97 +2,94 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Runtime.InteropServices;
|
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")]
|
if (IntPtr.Size == 8)
|
||||||
public static extern bool AttachConsole(int dwProcessId);
|
return GetWindowLong64(hWnd, nIndex);
|
||||||
|
else
|
||||||
|
return GetWindowLong32(hWnd, nIndex);
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public static extern bool FreeConsole();
|
public struct RECT
|
||||||
|
{
|
||||||
|
public int Left;
|
||||||
|
public int Top;
|
||||||
|
public int Right;
|
||||||
|
public int Bottom;
|
||||||
|
|
||||||
[DllImport("kernel32.dll")]
|
public RECT(Rectangle r)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if (IntPtr.Size == 8)
|
Left = r.Left;
|
||||||
return GetWindowLong64(hWnd, nIndex);
|
Top = r.Top;
|
||||||
else
|
Right = r.Right;
|
||||||
return GetWindowLong32(hWnd, nIndex);
|
Bottom = r.Bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
public RECT(int left, int top, int right, int bottom)
|
||||||
public struct RECT
|
|
||||||
{
|
{
|
||||||
public int Left;
|
Left = left;
|
||||||
public int Top;
|
Top = top;
|
||||||
public int Right;
|
Right = right;
|
||||||
public int Bottom;
|
Bottom = 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
public Rectangle ToRectangle() => Rectangle.FromLTRB(Left, Top, Right, Bottom);
|
||||||
public struct COPYDATASTRUCT
|
public Size Size => new Size(Right - Left, Bottom - Top);
|
||||||
{
|
public int Width => Right - Left;
|
||||||
public IntPtr dwData;
|
public int Height => Bottom - Top;
|
||||||
public int cbData;
|
}
|
||||||
[MarshalAs(UnmanagedType.LPTStr)]
|
|
||||||
public string lpData;
|
[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();
|
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);
|
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowException(Exception e)
|
public static void ShowException(Exception exception)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (TaskDialog<string> td = new TaskDialog<string>())
|
using (TaskDialog<string> td = new TaskDialog<string>())
|
||||||
{
|
{
|
||||||
td.MainInstruction = e.GetType().Name;
|
td.MainInstruction = exception.GetType().Name;
|
||||||
td.Content = e.Message;
|
td.Content = exception.Message;
|
||||||
td.MainIcon = MsgIcon.Error;
|
td.MainIcon = MsgIcon.Error;
|
||||||
td.ExpandedInformation = e.ToString();
|
td.ExpandedInformation = exception.ToString();
|
||||||
td.Footer = "[Copy Message](copymsg)";
|
td.Footer = "[Copy Message](copymsg)";
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
||||||
@@ -75,9 +75,9 @@ public class Msg
|
|||||||
td.Show();
|
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);
|
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,9 +144,9 @@ public class Msg
|
|||||||
return td.Show();
|
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);
|
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,6 +235,7 @@ public class TaskDialog<T> : TaskDialogNative, IDisposable
|
|||||||
|
|
||||||
if (Path.GetFileName(lpszFileName.ToString().Replace(".vshost", "")) ==
|
if (Path.GetFileName(lpszFileName.ToString().Replace(".vshost", "")) ==
|
||||||
Path.GetFileName(Assembly.GetEntryAssembly().Location))
|
Path.GetFileName(Assembly.GetEntryAssembly().Location))
|
||||||
|
|
||||||
return foregroundWindow;
|
return foregroundWindow;
|
||||||
|
|
||||||
return IntPtr.Zero;
|
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
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("5.4.0.0")]
|
[assembly: AssemblyVersion("5.4.2.0")]
|
||||||
[assembly: AssemblyFileVersion("5.4.0.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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to
|
/// Looks up a localized string similar to
|
||||||
/// # This file defines the input (keys and mouse) bindings of mpv and mpv.net
|
/// # This file defines the key and mouse bindings and the context menu
|
||||||
/// # and it also defines the context menu of mpv.net. mpv.net has an input
|
/// # of mpv.net. A input and config editor can be found in mpv.net's
|
||||||
/// # editor and an config editor as alternative to editing conf text files.
|
/// # context menu under 'Settings'. The defaults of this file can be found at:
|
||||||
/// # 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:
|
|
||||||
///
|
///
|
||||||
/// # https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt
|
/// # 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>
|
/// </summary>
|
||||||
internal static string inputConf {
|
internal static string inputConf {
|
||||||
get {
|
get {
|
||||||
@@ -83,21 +82,21 @@ namespace mpvnet.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to
|
/// Looks up a localized string similar to input-default-bindings = no
|
||||||
///# manual: https://mpv.io/manual/master/
|
|
||||||
///
|
|
||||||
///# defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt
|
|
||||||
///
|
|
||||||
///input-ar-delay = 500
|
///input-ar-delay = 500
|
||||||
///input-ar-rate = 20
|
///input-ar-rate = 20
|
||||||
///volume = 50
|
|
||||||
///hwdec = yes
|
|
||||||
///keep-open = yes
|
///keep-open = yes
|
||||||
///keep-open-pause = no
|
///keep-open-pause = no
|
||||||
///osd-playing-msg = '${filename}'
|
///osd-playing-msg = '${filename}'
|
||||||
|
///script-opts=osc-scalewindowed=1.5
|
||||||
///screenshot-directory = '~~desktop/'
|
///screenshot-directory = '~~desktop/'
|
||||||
///input-default-bindings = no
|
///cscale = spline36
|
||||||
///script-opts=osc-scalewindowed=1.5.
|
///dscale = spline36
|
||||||
|
///scale = spline36
|
||||||
|
///hwdec = yes
|
||||||
|
///
|
||||||
|
///[protocol.https]
|
||||||
|
///osd-playing-msg = '${media-title}'.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string mpvConf {
|
internal static string mpvConf {
|
||||||
get {
|
get {
|
||||||
@@ -143,24 +142,11 @@ namespace mpvnet.Properties {
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to [[settings]]
|
/// Looks up a localized string similar to [[settings]]
|
||||||
///name = "dark-mode"
|
///name = "process-instance"
|
||||||
///default = "always"
|
///default = "single"
|
||||||
///filter = "General"
|
///filter = "General"
|
||||||
///help = "Enables a dark theme. (mpv.net specific setting)"
|
///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 = "always" },
|
///options = [{ name = "multi", help = "Create a new process everytime the shell starts mpv.net [rest of string was truncated]";.
|
||||||
/// { 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]";.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string mpvNetConfToml {
|
internal static string mpvNetConfToml {
|
||||||
get {
|
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.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 {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
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
|
Ctrl+r script-message-to repl type "" #menu: Tools > Show REPL
|
||||||
l ab-loop #menu: Tools > Set/clear A-B loop points
|
l ab-loop #menu: Tools > Set/clear A-B loop points
|
||||||
L cycle-values loop-file "inf" "no" #menu: Tools > Toggle infinite file looping
|
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
|
Ctrl+h cycle-values hwdec "auto" "no" #menu: Tools > Toggle Hardware Decoding
|
||||||
_ script-message mpv.net show-setup-dialog #menu: Tools > OS Setup...
|
_ script-message mpv.net show-setup-dialog #menu: Tools > OS Setup...
|
||||||
|
|
||||||
|
|||||||
@@ -10,3 +10,6 @@ cscale = spline36
|
|||||||
dscale = spline36
|
dscale = spline36
|
||||||
scale = spline36
|
scale = spline36
|
||||||
hwdec = yes
|
hwdec = yes
|
||||||
|
|
||||||
|
[protocol.https]
|
||||||
|
osd-playing-msg = '${media-title}'
|
||||||
@@ -1,15 +1,8 @@
|
|||||||
[[settings]]
|
[[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"
|
name = "process-instance"
|
||||||
default = "single"
|
default = "single"
|
||||||
filter = "General"
|
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" },
|
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 = "single", help = "Force a single process everytime the shell starts mpv.net" },
|
||||||
{ name = "queue", help = "Force a single process and add files to playlist" }]
|
{ name = "queue", help = "Force a single process and add files to playlist" }]
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ using System.IO;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Management.Automation.Runspaces;
|
using System.Management.Automation.Runspaces;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Management.Automation;
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
public class PowerShellScript
|
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())
|
using (Runspace runspace = RunspaceFactory.CreateRunspace())
|
||||||
{
|
{
|
||||||
@@ -23,57 +23,53 @@ namespace mpvnet
|
|||||||
"Using namespace System\n" +
|
"Using namespace System\n" +
|
||||||
"[System.Reflection.Assembly]::LoadWithPartialName(\"mpvnet\")\n");
|
"[System.Reflection.Assembly]::LoadWithPartialName(\"mpvnet\")\n");
|
||||||
|
|
||||||
pipeline.Commands.AddScript(code);
|
pipeline.Commands.AddScript(File.ReadAllText(filepath));
|
||||||
|
|
||||||
if (parameters != null)
|
if (parameters != null)
|
||||||
foreach (var i in parameters)
|
foreach (string i in parameters)
|
||||||
pipeline.Commands[1].Parameters.Add(null, i);
|
pipeline.Commands[1].Parameters.Add(null, i);
|
||||||
|
|
||||||
try
|
PowerShellOutput output = new PowerShellOutput();
|
||||||
{
|
output.ModuleName = Path.GetFileName(filepath);
|
||||||
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");
|
|
||||||
|
|
||||||
if (Convert.ToInt32(pipeline2.Invoke()[0].ToString()) < 51)
|
pipeline.Output.DataReady += output.Output_DataReady;
|
||||||
throw new Exception();
|
pipeline.Error.DataReady += output.Error_DataReady;
|
||||||
}
|
|
||||||
}
|
runspace.SessionStateProxy.SetVariable("Output", output);
|
||||||
catch (Exception e2)
|
|
||||||
{
|
try {
|
||||||
Msg.ShowError("PowerShell Setup Problem\n\nEnsure you have at least PowerShell 5.1 installed.", e2.ToString());
|
pipeline.Invoke();
|
||||||
return null;
|
}
|
||||||
}
|
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);
|
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())
|
foreach (var eventInfo in typeof(mp).GetEvents())
|
||||||
{
|
{
|
||||||
if (eventInfo.Name.ToLower() ==
|
if (eventInfo.Name.ToLower() ==
|
||||||
Path.GetFileNameWithoutExtension(filePath).ToLower().Replace("-", ""))
|
Path.GetFileNameWithoutExtension(filepath).ToLower().Replace("-", ""))
|
||||||
{
|
{
|
||||||
PowerShellEventObject eventObject = new PowerShellEventObject();
|
PowerShellEventObject eventObject = new PowerShellEventObject();
|
||||||
MethodInfo mi;
|
MethodInfo mi;
|
||||||
eventObject.FilePath = filePath;
|
eventObject.Filepath = filepath;
|
||||||
|
|
||||||
if (eventInfo.EventHandlerType == typeof(Action))
|
if (eventInfo.EventHandlerType == typeof(Action))
|
||||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.Invoke));
|
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.Invoke));
|
||||||
else if (eventInfo.EventHandlerType == typeof(Action<EndFileEventMode>))
|
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[]>))
|
else if (eventInfo.EventHandlerType == typeof(Action<string[]>))
|
||||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeStrings));
|
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeStrings));
|
||||||
else
|
else
|
||||||
@@ -86,7 +82,33 @@ namespace mpvnet
|
|||||||
return;
|
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 EventInfo EventInfo { get; set; }
|
||||||
public Delegate Delegate { 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 Invoke() => PowerShellScript.Execute(Filepath);
|
||||||
|
public void InvokeEndFile(EndFileEventMode arg) => PowerShellScript.Execute(Filepath, arg.ToString());
|
||||||
public void InvokeEndFileEventMode(EndFileEventMode arg)
|
public void InvokeStrings(string[] args) => PowerShellScript.Execute(Filepath, args);
|
||||||
{
|
|
||||||
Task.Run(() => PowerShellScript.Execute(File.ReadAllText(FilePath), new [] { arg.ToString() }));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InvokeStrings(string[] args)
|
|
||||||
{
|
|
||||||
Task.Run(() => PowerShellScript.Execute(File.ReadAllText(FilePath), args));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
using Microsoft.Scripting;
|
using Microsoft.Scripting;
|
||||||
@@ -15,7 +16,7 @@ namespace mpvnet
|
|||||||
ScriptEngine engine;
|
ScriptEngine engine;
|
||||||
ScriptScope scope;
|
ScriptScope scope;
|
||||||
|
|
||||||
public PythonScript(string code)
|
public PythonScript(string scriptPath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -26,14 +27,14 @@ namespace mpvnet
|
|||||||
engine.Execute("clr.AddReference(\"mpvnet\")", scope);
|
engine.Execute("clr.AddReference(\"mpvnet\")", scope);
|
||||||
engine.Execute("import mpvnet", scope);
|
engine.Execute("import mpvnet", scope);
|
||||||
engine.Execute("from mpvnet import *", scope);
|
engine.Execute("from mpvnet import *", scope);
|
||||||
engine.Execute(code, scope);
|
engine.Execute(File.ReadAllText(scriptPath), scope);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (ex is SyntaxErrorException e)
|
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
|
else
|
||||||
Msg.ShowException(ex);
|
Msg.ShowError(ex.GetType().Name, ex.Message + "\n\n" + Path.GetFileName(scriptPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion} ({File.GetLastWriteTime(System.Windows.Forms.Application.ExecutablePath).ToShortDateString()})";
|
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();
|
protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();
|
||||||
|
|||||||
@@ -200,8 +200,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
private void FilterListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void FilterListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.AddedItems.Count > 0)
|
if (e.AddedItems.Count > 0) SearchControl.Text = e.AddedItems[0] + ":";
|
||||||
SearchControl.Text = e.AddedItems[0].ToString() + ":";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenSettingsTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
|
private void OpenSettingsTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ namespace mpvnet
|
|||||||
StringBuilder buf = new StringBuilder(bufsize);
|
StringBuilder buf = new StringBuilder(bufsize);
|
||||||
Everything_SetSearch(searchtext);
|
Everything_SetSearch(searchtext);
|
||||||
Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH);
|
Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH);
|
||||||
Everything_SetSort(EVERYTHING_SORT_SIZE_DESCENDING);
|
|
||||||
Everything_Query(true);
|
Everything_Query(true);
|
||||||
|
|
||||||
for (i = 0; i < Everything_GetNumResults(); i++)
|
for (i = 0; i < Everything_GetNumResults(); i++)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace mpvnet
|
|||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
for (int i = 0; i < 13; i++)
|
for (int i = 0; i < 13; i++)
|
||||||
if ("D" + i.ToString() == text)
|
if ("D" + i == text)
|
||||||
text = text.Substring(1);
|
text = text.Substring(1);
|
||||||
|
|
||||||
switch (e.KeyCode)
|
switch (e.KeyCode)
|
||||||
@@ -59,7 +59,7 @@ namespace mpvnet
|
|||||||
case WF.Keys.NumPad7:
|
case WF.Keys.NumPad7:
|
||||||
case WF.Keys.NumPad8:
|
case WF.Keys.NumPad8:
|
||||||
case WF.Keys.NumPad9:
|
case WF.Keys.NumPad9:
|
||||||
text = "KP" + e.KeyCode.ToString()[6].ToString(); break;
|
text = "KP" + e.KeyCode.ToString()[6]; break;
|
||||||
case WF.Keys.Space:
|
case WF.Keys.Space:
|
||||||
text = "Space"; break;
|
text = "Space"; break;
|
||||||
case WF.Keys.Enter:
|
case WF.Keys.Enter:
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ namespace mpvnet
|
|||||||
mp.observe_property_string("vid", PropChangeVid);
|
mp.observe_property_string("vid", PropChangeVid);
|
||||||
mp.observe_property_int("edition", PropChangeEdition);
|
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());
|
AppDomain.CurrentDomain.UnhandledException += (sender, e) => Msg.ShowError(e.ExceptionObject.ToString());
|
||||||
Application.ThreadException += (sender, e) => Msg.ShowException(e.Exception);
|
Application.ThreadException += (sender, e) => Msg.ShowException(e.Exception);
|
||||||
@@ -68,11 +69,18 @@ namespace mpvnet
|
|||||||
ContextMenu.Opened += ContextMenu_Opened;
|
ContextMenu.Opened += ContextMenu_Opened;
|
||||||
ContextMenu.Opening += ContextMenu_Opening;
|
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;
|
int targetIndex = mp.Screen;
|
||||||
Screen[] screens = Screen.AllScreens;
|
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])];
|
Screen screen = screens[Array.IndexOf(screens, screens[targetIndex])];
|
||||||
Rectangle target = screen.Bounds;
|
Rectangle target = screen.Bounds;
|
||||||
Left = target.X + (target.Width - Width) / 2;
|
Left = target.X + (target.Width - Width) / 2;
|
||||||
@@ -87,7 +95,8 @@ namespace mpvnet
|
|||||||
Top = posY - Height / 2;
|
Top = posY - Height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App.Maximized) WindowState = FormWindowState.Maximized;
|
if (App.Maximized)
|
||||||
|
WindowState = FormWindowState.Maximized;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -205,8 +214,10 @@ namespace mpvnet
|
|||||||
if (recent != null)
|
if (recent != null)
|
||||||
{
|
{
|
||||||
recent.DropDownItems.Clear();
|
recent.DropDownItems.Clear();
|
||||||
|
|
||||||
foreach (string path in RecentFiles)
|
foreach (string path in RecentFiles)
|
||||||
MenuItem.Add(recent.DropDownItems, path, () => mp.Load(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control)));
|
MenuItem.Add(recent.DropDownItems, path, () => mp.Load(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control)));
|
||||||
|
|
||||||
recent.DropDownItems.Add(new ToolStripSeparator());
|
recent.DropDownItems.Add(new ToolStripSeparator());
|
||||||
MenuItem mi = new MenuItem("Clear List");
|
MenuItem mi = new MenuItem("Clear List");
|
||||||
mi.Action = () => RecentFiles.Clear();
|
mi.Action = () => RecentFiles.Clear();
|
||||||
@@ -381,15 +392,16 @@ namespace mpvnet
|
|||||||
|
|
||||||
BeginInvoke(new Action(() => {
|
BeginInvoke(new Action(() => {
|
||||||
if (path.Contains("://"))
|
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("\\\\"))
|
else if (path.Contains(":\\") || path.StartsWith("\\\\"))
|
||||||
Text = path.FileName() + " - mpv.net " + Application.ProductVersion;
|
Text = path.FileName() + " - mpv.net " + Application.ProductVersion;
|
||||||
else
|
else
|
||||||
Text = "mpv.net " + Application.ProductVersion;
|
Text = "mpv.net " + Application.ProductVersion;
|
||||||
|
|
||||||
ProgressTimer.Interval = (int)(mp.Duration.TotalMilliseconds / 99);
|
int interval = (int)(mp.Duration.TotalMilliseconds / 100);
|
||||||
if (ProgressTimer.Interval < 100) ProgressTimer.Interval = 100;
|
if (interval < 100) interval = 100;
|
||||||
if (ProgressTimer.Interval > 999) ProgressTimer.Interval = 999;
|
if (interval > 1000) interval = 1000;
|
||||||
|
ProgressTimer.Interval = interval;
|
||||||
UpdateProgressBar();
|
UpdateProgressBar();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -408,7 +420,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
protected override void WndProc(ref Message m)
|
||||||
{
|
{
|
||||||
//Debug.WriteLine(m);
|
Debug.WriteLine(m);
|
||||||
|
|
||||||
switch (m.Msg)
|
switch (m.Msg)
|
||||||
{
|
{
|
||||||
@@ -444,24 +456,31 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x02E0: // WM_DPICHANGED
|
case 0x02E0: // WM_DPICHANGED
|
||||||
if (!WasShown) break;
|
if (!WasShown)
|
||||||
|
break;
|
||||||
var r2 = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
var r2 = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
||||||
Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0);
|
Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0);
|
||||||
break;
|
break;
|
||||||
|
case 0x112: // WM_SYSCOMMAND
|
||||||
|
if (m.WParam.ToInt32() == 0xf120) // SC_RESTORE
|
||||||
|
SetFormPosAndSize();
|
||||||
|
break;
|
||||||
case 0x0214: // WM_SIZING
|
case 0x0214: // WM_SIZING
|
||||||
var rc = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
var rc = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
||||||
var r = rc;
|
var r = rc;
|
||||||
NativeHelp.SubtractWindowBorders(Handle, ref r);
|
NativeHelp.SubtractWindowBorders(Handle, ref r);
|
||||||
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
|
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
|
||||||
Size s = mp.VideoSize;
|
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;
|
float aspect = s.Width / (float)s.Height;
|
||||||
int d_w = Convert.ToInt32(c_h * aspect - c_w);
|
int d_w = Convert.ToInt32(c_h * aspect - c_w);
|
||||||
int d_h = Convert.ToInt32(c_w / aspect - c_h);
|
int d_h = Convert.ToInt32(c_w / aspect - c_h);
|
||||||
int[] d_corners = { d_w, d_h, -d_w, -d_h };
|
int[] d_corners = { d_w, d_h, -d_w, -d_h };
|
||||||
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
|
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
|
||||||
int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
|
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);
|
Marshal.StructureToPtr<Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
|
||||||
m.Result = new IntPtr(1);
|
m.Result = new IntPtr(1);
|
||||||
return;
|
return;
|
||||||
@@ -486,7 +505,7 @@ namespace mpvnet
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m.Msg == TaskbarButtonCreatedMessage)
|
if (m.Msg == TaskbarButtonCreatedMessage && mp.TaskbarProgress)
|
||||||
{
|
{
|
||||||
Taskbar = new Taskbar(Handle);
|
Taskbar = new Taskbar(Handle);
|
||||||
ProgressTimer.Start();
|
ProgressTimer.Start();
|
||||||
@@ -543,7 +562,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
void PropChangePause(bool enabled)
|
void PropChangePause(bool enabled)
|
||||||
{
|
{
|
||||||
if (Taskbar != null)
|
if (Taskbar != null && mp.TaskbarProgress)
|
||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled)
|
||||||
Taskbar.SetState(TaskbarStates.Paused);
|
Taskbar.SetState(TaskbarStates.Paused);
|
||||||
@@ -570,25 +589,18 @@ namespace mpvnet
|
|||||||
ContextMenuStrip = ContextMenu;
|
ContextMenuStrip = ContextMenu;
|
||||||
WPF.WPF.Init();
|
WPF.WPF.Init();
|
||||||
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
||||||
CheckClipboardForURL();
|
|
||||||
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
|
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
|
||||||
WasShown = true;
|
WasShown = true;
|
||||||
Task.Run(() => mp.LoadScripts());
|
mp.LoadScripts();
|
||||||
Task.Run(() => mp.Extension = new Extension());
|
Task.Run(() => App.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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnResize(EventArgs e)
|
protected override void OnResize(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnResize(e);
|
base.OnResize(e);
|
||||||
if (mp.IsLogoVisible) mp.ShowLogo();
|
|
||||||
|
if (mp.IsLogoVisible)
|
||||||
|
mp.ShowLogo();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||||
@@ -648,23 +660,5 @@ namespace mpvnet
|
|||||||
base.OnLostFocus(e);
|
base.OnLostFocus(e);
|
||||||
CursorHelp.Show();
|
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.ComponentModel;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Text;
|
using System.Drawing.Text;
|
||||||
using Microsoft.Win32;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>mpvnet</RootNamespace>
|
<RootNamespace>mpvnet</RootNamespace>
|
||||||
<AssemblyName>mpvnet</AssemblyName>
|
<AssemblyName>mpvnet</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using System.Windows.Forms;
|
|||||||
using WinForms = System.Windows.Forms;
|
using WinForms = System.Windows.Forms;
|
||||||
|
|
||||||
using static mpvnet.libmpv;
|
using static mpvnet.libmpv;
|
||||||
using static mpvnet.Native;
|
using static Native;
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,6 @@ namespace mpvnet
|
|||||||
public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
|
public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
|
||||||
public static IntPtr Handle { get; set; }
|
public static IntPtr Handle { get; set; }
|
||||||
public static IntPtr WindowHandle { 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 List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
|
||||||
public static Size VideoSize { get; set; }
|
public static Size VideoSize { get; set; }
|
||||||
public static TimeSpan Duration;
|
public static TimeSpan Duration;
|
||||||
@@ -149,7 +148,7 @@ namespace mpvnet
|
|||||||
get {
|
get {
|
||||||
if (_ConfigFolder == null)
|
if (_ConfigFolder == null)
|
||||||
{
|
{
|
||||||
string portableFolder = PathHelp.StartupPath + "portable_config\\";
|
string portableFolder = Folder.Startup + "portable_config\\";
|
||||||
_ConfigFolder = portableFolder;
|
_ConfigFolder = portableFolder;
|
||||||
|
|
||||||
if (!Directory.Exists(_ConfigFolder))
|
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.");
|
Msg.ShowError("Startup folder and config folder cannot be identical, using portable_config instead.");
|
||||||
_ConfigFolder = portableFolder;
|
_ConfigFolder = portableFolder;
|
||||||
@@ -237,9 +236,9 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void LoadMpvScripts()
|
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)
|
foreach (string path in startupScripts)
|
||||||
if ((path.EndsWith(".lua") || path.EndsWith(".js")) && KnownScripts.Contains(Path.GetFileName(path)))
|
if ((path.EndsWith(".lua") || path.EndsWith(".js")) && KnownScripts.Contains(Path.GetFileName(path)))
|
||||||
@@ -251,28 +250,28 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void LoadScripts()
|
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"))
|
if (scriptPath.EndsWith(".py"))
|
||||||
PythonScripts.Add(new PythonScript(File.ReadAllText(path)));
|
Task.Run(() => PythonScripts.Add(new PythonScript(scriptPath)));
|
||||||
else if (path.EndsWith(".ps1"))
|
else if (scriptPath.EndsWith(".ps1"))
|
||||||
PowerShellScript.Init(path);
|
Task.Run(() => PowerShellScript.Init(scriptPath));
|
||||||
}
|
}
|
||||||
else
|
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"))
|
if (Directory.Exists(ConfigFolder + "scripts"))
|
||||||
foreach (string scriptPath in Directory.GetFiles(ConfigFolder + "scripts"))
|
foreach (string scriptPath in Directory.GetFiles(ConfigFolder + "scripts"))
|
||||||
if (scriptPath.EndsWith(".py"))
|
if (scriptPath.EndsWith(".py"))
|
||||||
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
|
Task.Run(() => PythonScripts.Add(new PythonScript(scriptPath)));
|
||||||
else if (scriptPath.EndsWith(".ps1"))
|
else if (scriptPath.EndsWith(".ps1"))
|
||||||
PowerShellScript.Init(scriptPath);
|
Task.Run(() => PowerShellScript.Init(scriptPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EventLoop()
|
public static void EventLoop()
|
||||||
@@ -330,7 +329,10 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
VideoSizeAutoResetEvent.Set();
|
VideoSizeAutoResetEvent.Set();
|
||||||
Task.Run(new Action(() => ReadMetaData()));
|
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();
|
FileLoaded?.Invoke();
|
||||||
break;
|
break;
|
||||||
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
|
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
|
||||||
@@ -607,9 +609,12 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
else if (!preInit && !preInitProperties.Contains(left))
|
else if (!preInit && !preInitProperties.Contains(left))
|
||||||
{
|
{
|
||||||
mp.ProcessProperty(left, right);
|
if (!PrintCommandLineArgument(arg))
|
||||||
if (!App.ProcessProperty(left, right))
|
{
|
||||||
set_property_string(left, right, true);
|
mp.ProcessProperty(left, right);
|
||||||
|
if (!App.ProcessProperty(left, right))
|
||||||
|
set_property_string(left, right, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -629,7 +634,6 @@ namespace mpvnet
|
|||||||
i.Contains(":\\") || i.StartsWith("\\\\") || File.Exists(i)))
|
i.Contains(":\\") || i.StartsWith("\\\\") || File.Exists(i)))
|
||||||
{
|
{
|
||||||
files.Add(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 DateTime LastLoad;
|
||||||
|
|
||||||
public static void Load(string[] files, bool loadFolder, bool append)
|
public static void Load(string[] files, bool loadFolder, bool append)
|
||||||
@@ -735,12 +753,14 @@ namespace mpvnet
|
|||||||
|
|
||||||
static void WriteHistory(string path)
|
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);
|
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) +
|
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;
|
LastHistoryPath = path;
|
||||||
LastHistoryStartDateTime = DateTime.Now;
|
LastHistoryStartDateTime = DateTime.Now;
|
||||||
|
|||||||
Reference in New Issue
Block a user