Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c053bb5eb | ||
|
|
83658aa476 | ||
|
|
e0111b6f12 | ||
|
|
e308bbf928 | ||
|
|
1817fbc0fd | ||
|
|
3b149aea54 |
18
Changelog.md
18
Changelog.md
@@ -1,3 +1,21 @@
|
|||||||
|
### 4.7
|
||||||
|
|
||||||
|
- remember-height was replaced with start-size, when start-size is set
|
||||||
|
to video the main video starts directly with the native video size,
|
||||||
|
before it was starting with the autofit size first and was only
|
||||||
|
afterwards resized to the native video size
|
||||||
|
- on exit the window location can be saved with remember-position
|
||||||
|
- in the learn window of the input editor underscores were stripped
|
||||||
|
because they have a special meaning in WPF labels
|
||||||
|
- keys/input not working for MBTN_LEFT_DBL, MBTN_BACK, MBTN_FORWARD
|
||||||
|
- in the learn window of the input editor support was added for
|
||||||
|
mouse left, mouse left double, mouse mid, mouse forward, mouse back
|
||||||
|
- libmpv updated to shinchiro 2019-07-07
|
||||||
|
- when border is none it wasn't possible to minimize the window from
|
||||||
|
the task bar because this is the WinForms default behavier. This
|
||||||
|
was fixed by calling Spy++ to the rescue and adding WS_MINIMIZEBOX
|
||||||
|
in CreateParams
|
||||||
|
|
||||||
### 4.6
|
### 4.6
|
||||||
|
|
||||||
- fix for middle mouse button not working
|
- fix for middle mouse button not working
|
||||||
|
|||||||
@@ -102,9 +102,9 @@ mpv.net is meant to be a small single person project, it's designed to be mpv co
|
|||||||
|
|
||||||
### Target Audience
|
### Target Audience
|
||||||
|
|
||||||
The target audience of mpv.net are Windows programmers and users that need something more advanced than common media players.
|
The target audience of mpv.net are programmers, nerds and software enthusiasts that need something more advanced than typical media players.
|
||||||
|
|
||||||
Furthermore mpv.net is well suited for Windows users who are interested to learn about the Linux operating system and portable apps, even though mpv.net self is not portable.
|
Furthermore mpv.net is well suited for users who are interested to learn mpv, Linux, portable apps and the command line.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ Third party components:
|
|||||||
|
|
||||||
Please click on the star at the top of the page and like mpv.net at [alternativeto.net](https://alternativeto.net/software/mpv-net/).
|
Please click on the star at the top of the page and like mpv.net at [alternativeto.net](https://alternativeto.net/software/mpv-net/).
|
||||||
|
|
||||||
|
If you like you can express your appreciation for my player by sending little beer money with paypal.
|
||||||
|
|
||||||
|
<https://www.paypal.me/stax76>
|
||||||
|
|
||||||
### Links
|
### Links
|
||||||
|
|
||||||
mpv manual: <https://mpv.io/manual/master/>
|
mpv manual: <https://mpv.io/manual/master/>
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ namespace mpvnet
|
|||||||
public static string[] SubtitleTypes { get; } = "srt ass idx sup ttxt ssa smi".Split(' ');
|
public static string[] SubtitleTypes { get; } = "srt ass idx sup ttxt ssa smi".Split(' ');
|
||||||
public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" };
|
public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" };
|
||||||
|
|
||||||
|
public static bool RememberHeight { get; set; } = true;
|
||||||
|
public static bool RememberPosition { get; set; }
|
||||||
public static bool DebugMode { get; set; } = false;
|
public static bool DebugMode { get; set; } = false;
|
||||||
|
|
||||||
public static bool IsDarkMode {
|
public static bool IsDarkMode {
|
||||||
@@ -36,6 +38,9 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
string dummy = mp.ConfFolder;
|
||||||
|
var dummy2 = mp.Conf;
|
||||||
|
|
||||||
foreach (var i in Conf)
|
foreach (var i in Conf)
|
||||||
ProcessProperty(i.Key, i.Value);
|
ProcessProperty(i.Key, i.Value);
|
||||||
|
|
||||||
@@ -83,6 +88,8 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
|
case "remember-position": RememberPosition = value == "yes"; break;
|
||||||
|
case "start-size": RememberHeight = value == "previous"; break;
|
||||||
case "process-instance": ProcessInstance = value; break;
|
case "process-instance": ProcessInstance = value; break;
|
||||||
case "dark-mode": DarkMode = value; break;
|
case "dark-mode": DarkMode = value; break;
|
||||||
case "debug-mode": DebugMode = value == "yes"; break;
|
case "debug-mode": DebugMode = value == "yes"; break;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace mpvnet
|
|||||||
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
|
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
|
||||||
private static extern IntPtr GetWindowLong64(IntPtr hWnd, int nIndex);
|
private static extern IntPtr GetWindowLong64(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex)
|
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
|
||||||
{
|
{
|
||||||
if (IntPtr.Size == 8)
|
if (IntPtr.Size == 8)
|
||||||
return GetWindowLong64(hWnd, nIndex);
|
return GetWindowLong64(hWnd, nIndex);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void AddWindowBorders(IntPtr hwnd, ref Native.RECT rc)
|
public static void AddWindowBorders(IntPtr hwnd, ref Native.RECT rc)
|
||||||
{
|
{
|
||||||
Native.AdjustWindowRect(ref rc, (uint)Native.GetWindowLongPtr(hwnd, -16 /* GWL_STYLE */), false);
|
Native.AdjustWindowRect(ref rc, (uint)Native.GetWindowLong(hwnd, -16 /* GWL_STYLE */), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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("4.6.0.0")]
|
[assembly: AssemblyVersion("4.7.0.0")]
|
||||||
[assembly: AssemblyFileVersion("4.6.0.0")]
|
[assembly: AssemblyFileVersion("4.7.0.0")]
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
# mpv input keys: https://github.com/stax76/mpv.net/wiki/mpv-input-keys
|
# mpv input keys: https://github.com/stax76/mpv.net/wiki/mpv-input-keys
|
||||||
|
|
||||||
|
# run mpv.net in input test mode with: mpvnet --input-test
|
||||||
|
|
||||||
o script-message mpv.net open-files #menu: Open > Open Files...
|
o script-message mpv.net open-files #menu: Open > Open Files...
|
||||||
u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard
|
u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard
|
||||||
_ ignore #menu: Open > -
|
_ ignore #menu: Open > -
|
||||||
@@ -183,3 +185,4 @@
|
|||||||
Ctrl+Wheel_Up no-osd seek 7
|
Ctrl+Wheel_Up no-osd seek 7
|
||||||
Ctrl+Wheel_Down no-osd seek -7
|
Ctrl+Wheel_Down no-osd seek -7
|
||||||
MBTN_LEFT_DBL cycle fullscreen
|
MBTN_LEFT_DBL cycle fullscreen
|
||||||
|
KP_ENTER cycle fullscreen
|
||||||
@@ -254,14 +254,6 @@ default = "50%"
|
|||||||
filter = "Screen"
|
filter = "Screen"
|
||||||
help = "Set the initial window size in percent. Please note that this setting is only partly implemented in mpv.net, accepted are only integer values with percent sign added. Default: 50%"
|
help = "Set the initial window size in percent. Please note that this setting is only partly implemented in mpv.net, accepted are only integer values with percent sign added. Default: 50%"
|
||||||
|
|
||||||
[[settings]]
|
|
||||||
name = "remember-height"
|
|
||||||
default = "yes"
|
|
||||||
filter = "Screen"
|
|
||||||
help = "mpv.net specific setting to remember the window height, otherwise the video's native resolution is used."
|
|
||||||
options = [{ name = "yes" },
|
|
||||||
{ name = "no" }]
|
|
||||||
|
|
||||||
[[settings]]
|
[[settings]]
|
||||||
name = "keep-open-pause"
|
name = "keep-open-pause"
|
||||||
default = "yes"
|
default = "yes"
|
||||||
|
|||||||
@@ -29,3 +29,19 @@ filter = "General"
|
|||||||
help = "mpv.net specific setting that writes debug info to a file located on the desktop."
|
help = "mpv.net specific setting that writes debug info to a file located on the desktop."
|
||||||
options = [{ name = "yes" },
|
options = [{ name = "yes" },
|
||||||
{ name = "no" }]
|
{ name = "no" }]
|
||||||
|
|
||||||
|
[[settings]]
|
||||||
|
name = "start-size"
|
||||||
|
default = "previous"
|
||||||
|
filter = "Screen"
|
||||||
|
help = "mpv.net specific setting to remember the window height in the current session, otherwise the video's native resolution is used."
|
||||||
|
options = [{ name = "video", help = "Window size is set to native video resolution" },
|
||||||
|
{ name = "previous", help = "Window size is remembered but only from the current session" }]
|
||||||
|
|
||||||
|
[[settings]]
|
||||||
|
name = "remember-position"
|
||||||
|
default = "no"
|
||||||
|
filter = "Screen"
|
||||||
|
help = "mpv.net specific setting to save the window position on exit."
|
||||||
|
options = [{ name = "yes" },
|
||||||
|
{ name = "no" }]
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Learn Input" Height="200" Width="400" WindowStartupLocation="CenterOwner"
|
Title="Learn Input" Height="200" Width="400" WindowStartupLocation="CenterOwner"
|
||||||
ResizeMode="NoResize" Loaded="Window_Loaded" Background="Black" MouseWheel="Window_MouseWheel">
|
ResizeMode="NoResize" Loaded="Window_Loaded" Background="Black" MouseWheel="Window_MouseWheel" MouseUp="Window_MouseUp" MouseDoubleClick="Window_MouseDoubleClick">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Label x:Name="MenuLabel" Grid.ColumnSpan="2" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16"></Label>
|
<TextBlock x:Name="MenuTextBlock" Grid.ColumnSpan="2" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16"></TextBlock>
|
||||||
<Label x:Name="KeyLabel" Grid.Row="1" Grid.ColumnSpan="2" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="16"></Label>
|
<TextBlock x:Name="KeyTextBlock" Grid.Row="1" Grid.ColumnSpan="2" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="16"></TextBlock>
|
||||||
<Button x:Name="ConfirmButton" Grid.Row="2" Click="ConfirmButton_Click">Confirm</Button>
|
<Button x:Name="ConfirmButton" Grid.Row="2" Click="ConfirmButton_Click">Confirm</Button>
|
||||||
<Button x:Name="ClearButton" Grid.Row="2" Click="ClearButton_Click" Grid.Column="1">Clear</Button>
|
<Button x:Name="ClearButton" Grid.Row="2" Click="ClearButton_Click" Grid.Column="1">Clear</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
@@ -12,10 +13,7 @@ namespace mpvnet
|
|||||||
public CommandItem InputItem { get; set; }
|
public CommandItem InputItem { get; set; }
|
||||||
public string NewKey { get; set; } = "";
|
public string NewKey { get; set; } = "";
|
||||||
|
|
||||||
public LearnWindow()
|
public LearnWindow() => InitializeComponent();
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||||
{
|
{
|
||||||
@@ -43,8 +41,7 @@ namespace mpvnet
|
|||||||
else
|
else
|
||||||
try {
|
try {
|
||||||
text = Convert.ToChar(charValue).ToString().ToLower().Trim();
|
text = Convert.ToChar(charValue).ToString().ToLower().Trim();
|
||||||
}
|
} catch {}
|
||||||
catch {}
|
|
||||||
|
|
||||||
for (int i = 0; i < 13; i++)
|
for (int i = 0; i < 13; i++)
|
||||||
if ("D" + i.ToString() == text)
|
if ("D" + i.ToString() == text)
|
||||||
@@ -144,8 +141,8 @@ namespace mpvnet
|
|||||||
void SetKey(string key)
|
void SetKey(string key)
|
||||||
{
|
{
|
||||||
NewKey = key;
|
NewKey = key;
|
||||||
MenuLabel.Content = InputItem.Path;
|
MenuTextBlock.Text = InputItem.Path;
|
||||||
KeyLabel.Content = key;
|
KeyTextBlock.Text = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
@@ -295,5 +292,38 @@ namespace mpvnet
|
|||||||
else
|
else
|
||||||
SetKey("WHEEL_DOWN");
|
SetKey("WHEEL_DOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.ChangedButton)
|
||||||
|
{
|
||||||
|
case MouseButton.Left:
|
||||||
|
if (BlockMBTN_LEFT)
|
||||||
|
BlockMBTN_LEFT = false;
|
||||||
|
else
|
||||||
|
SetKey("MBTN_LEFT");
|
||||||
|
break;
|
||||||
|
case MouseButton.Middle:
|
||||||
|
SetKey("MBTN_MID");
|
||||||
|
break;
|
||||||
|
case MouseButton.XButton1:
|
||||||
|
SetKey("MBTN_BACK");
|
||||||
|
break;
|
||||||
|
case MouseButton.XButton2:
|
||||||
|
SetKey("MBTN_FORWARD");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BlockMBTN_LEFT;
|
||||||
|
|
||||||
|
private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.ChangedButton == MouseButton.Left)
|
||||||
|
{
|
||||||
|
SetKey("MBTN_LEFT_DBL");
|
||||||
|
BlockMBTN_LEFT = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
2
mpv.net/WinForms/MainForm.Designer.cs
generated
2
mpv.net/WinForms/MainForm.Designer.cs
generated
@@ -45,7 +45,7 @@
|
|||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||||
this.BackColor = System.Drawing.Color.Black;
|
this.BackColor = System.Drawing.Color.Black;
|
||||||
this.ClientSize = new System.Drawing.Size(606, 368);
|
this.ClientSize = new System.Drawing.Size(1777, 1109);
|
||||||
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(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.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Linq;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
@@ -36,7 +37,6 @@ namespace mpvnet
|
|||||||
WPF.WPF.Init();
|
WPF.WPF.Init();
|
||||||
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
||||||
Hwnd = Handle;
|
Hwnd = Handle;
|
||||||
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
|
|
||||||
Text += " " + Application.ProductVersion;
|
Text += " " + Application.ProductVersion;
|
||||||
|
|
||||||
object recent = RegHelp.GetObject(App.RegPath, "Recent");
|
object recent = RegHelp.GetObject(App.RegPath, "Recent");
|
||||||
@@ -46,11 +46,40 @@ namespace mpvnet
|
|||||||
else
|
else
|
||||||
RecentFiles = new List<string>();
|
RecentFiles = new List<string>();
|
||||||
|
|
||||||
var dummy = mp.Conf;
|
|
||||||
App.ProcessCommandLineEarly();
|
App.ProcessCommandLineEarly();
|
||||||
|
|
||||||
if (mp.Screen == -1) mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
|
if (mp.Screen == -1) mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
|
||||||
SetScreen(mp.Screen);
|
int targetIndex = mp.Screen;
|
||||||
CycleFullscreen(mp.Fullscreen);
|
Screen[] screens = Screen.AllScreens;
|
||||||
|
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;
|
||||||
|
Top = target.Y + (target.Height - Height) / 2;
|
||||||
|
|
||||||
|
int posX = RegHelp.GetInt(App.RegPath, "PosX");
|
||||||
|
int posY = RegHelp.GetInt(App.RegPath, "PosY");
|
||||||
|
|
||||||
|
if (posX != 0 && posY != 0 && App.RememberPosition)
|
||||||
|
{
|
||||||
|
Left = posX - Width / 2;
|
||||||
|
Top = posY - Height / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.Shutdown += Shutdown;
|
||||||
|
mp.VideoSizeChanged += VideoSizeChanged;
|
||||||
|
mp.FileLoaded += FileLoaded;
|
||||||
|
mp.Idle += Idle;
|
||||||
|
Task.Run(() => mp.Init());
|
||||||
|
mp.VideoSizeAutoResetEvent.WaitOne(1000);
|
||||||
|
mp.observe_property_bool("fullscreen", PropChangeFullscreen);
|
||||||
|
mp.observe_property_bool("ontop", PropChangeOnTop);
|
||||||
|
mp.observe_property_bool("border", PropChangeBorder);
|
||||||
|
mp.observe_property_string("sid", PropChangeSid);
|
||||||
|
mp.observe_property_string("aid", PropChangeAid);
|
||||||
|
mp.observe_property_string("vid", PropChangeVid);
|
||||||
|
mp.observe_property_int("edition", PropChangeEdition);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -60,7 +89,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
||||||
|
|
||||||
void Idle() => BeginInvoke(new Action(() => { Text = "mpv.net " + Application.ProductVersion; }));
|
void Idle() => BeginInvoke(new Action(() => Text = "mpv.net " + Application.ProductVersion));
|
||||||
|
|
||||||
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
|
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
|
||||||
|
|
||||||
@@ -192,54 +221,27 @@ namespace mpvnet
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SetScreen(int targetIndex)
|
|
||||||
{
|
|
||||||
Screen[] screens = Screen.AllScreens;
|
|
||||||
if (targetIndex < 0) targetIndex = 0;
|
|
||||||
if (targetIndex > screens.Length - 1) targetIndex = screens.Length - 1;
|
|
||||||
SetScreen(screens[Array.IndexOf(screens, screens[targetIndex])]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void SetScreen(Screen screen)
|
|
||||||
{
|
|
||||||
Rectangle target = screen.Bounds;
|
|
||||||
Left = target.X + Convert.ToInt32((target.Width - Width) / 2.0);
|
|
||||||
Top = target.Y + Convert.ToInt32((target.Height - Height) / 2.0);
|
|
||||||
SetStartFormPositionAndSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetStartFormPositionAndSize()
|
|
||||||
{
|
|
||||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
|
||||||
Screen screen = Screen.FromControl(this);
|
|
||||||
int height = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
|
|
||||||
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.Height);
|
|
||||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
|
||||||
var rect = new Native.RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
|
|
||||||
NativeHelp.AddWindowBorders(Handle, ref rect);
|
|
||||||
int left = middlePos.X - rect.Width / 2;
|
|
||||||
int top = middlePos.Y - rect.Height / 2;
|
|
||||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFormPosAndSize()
|
void SetFormPosAndSize()
|
||||||
{
|
{
|
||||||
if (IsFullscreen)
|
if (mp.Fullscreen)
|
||||||
|
{
|
||||||
|
CycleFullscreen(true);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Size size = mp.VideoSize;
|
Size size = mp.VideoSize;
|
||||||
Screen screen = Screen.FromControl(this);
|
Screen screen = Screen.FromControl(this);
|
||||||
int fixedHeight = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
|
int fixedHeight = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
|
||||||
|
|
||||||
if (size.Height == 0 || size.Width == 0 || size.Width / (float)size.Height < 1.2)
|
if (size.Height == 0 || size.Width == 0 || size.Width / (float)size.Height < 1.3)
|
||||||
{
|
{
|
||||||
size.Height = fixedHeight;
|
size.Height = fixedHeight;
|
||||||
size.Width = (int)(fixedHeight * 1.8);
|
size.Width = (int)(fixedHeight * 1.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
int height = size.Height;
|
int height = size.Height;
|
||||||
|
|
||||||
if (mp.RememberHeight)
|
if (App.RememberHeight)
|
||||||
height = ClientSize.Height;
|
height = ClientSize.Height;
|
||||||
|
|
||||||
if (height > screen.Bounds.Height * 0.9)
|
if (height > screen.Bounds.Height * 0.9)
|
||||||
@@ -251,10 +253,49 @@ namespace mpvnet
|
|||||||
NativeHelp.AddWindowBorders(Handle, ref rect);
|
NativeHelp.AddWindowBorders(Handle, ref rect);
|
||||||
int left = middlePos.X - rect.Width / 2;
|
int left = middlePos.X - rect.Width / 2;
|
||||||
int top = middlePos.Y - rect.Height / 2;
|
int top = middlePos.Y - rect.Height / 2;
|
||||||
|
|
||||||
Screen[] screens = Screen.AllScreens;
|
Screen[] screens = Screen.AllScreens;
|
||||||
|
int minLeft = screens.Select(val => val.WorkingArea.X).Min();
|
||||||
|
int maxRight = screens.Select(val => val.WorkingArea.Right).Max();
|
||||||
|
int minTop = screens.Select(val => val.WorkingArea.Y).Min();
|
||||||
|
int maxBottom = screens.Select(val => val.WorkingArea.Bottom).Max();
|
||||||
|
|
||||||
|
if (left < minLeft) left = minLeft;
|
||||||
|
if (left + rect.Width > maxRight) left = maxRight - rect.Width;
|
||||||
|
if (top < minTop) top = minTop;
|
||||||
|
if (top + rect.Height > maxBottom) top = maxBottom - rect.Height;
|
||||||
|
|
||||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CycleFullscreen(bool enabled)
|
||||||
|
{
|
||||||
|
mp.Fullscreen = enabled;
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
if (WindowState != FormWindowState.Maximized)
|
||||||
|
{
|
||||||
|
FormBorderStyle = FormBorderStyle.None;
|
||||||
|
WindowState = FormWindowState.Maximized;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (WindowState == FormWindowState.Maximized)
|
||||||
|
{
|
||||||
|
WindowState = FormWindowState.Normal;
|
||||||
|
|
||||||
|
if (mp.Border)
|
||||||
|
FormBorderStyle = FormBorderStyle.Sizable;
|
||||||
|
else
|
||||||
|
FormBorderStyle = FormBorderStyle.None;
|
||||||
|
|
||||||
|
SetFormPosAndSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void BuildMenu()
|
public void BuildMenu()
|
||||||
{
|
{
|
||||||
string content = File.ReadAllText(mp.InputConfPath);
|
string content = File.ReadAllText(mp.InputConfPath);
|
||||||
@@ -309,26 +350,11 @@ namespace mpvnet
|
|||||||
Msg.ShowError(e.ExceptionObject.ToString());
|
Msg.ShowError(e.ExceptionObject.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CycleFullscreen(bool enabled)
|
protected override CreateParams CreateParams {
|
||||||
{
|
get {
|
||||||
if (enabled)
|
CreateParams cp = base.CreateParams;
|
||||||
{
|
cp.Style |= 0x00020000 /* WS_MINIMIZEBOX */;
|
||||||
if (WindowState != FormWindowState.Maximized)
|
return cp;
|
||||||
{
|
|
||||||
FormBorderStyle = FormBorderStyle.None;
|
|
||||||
WindowState = FormWindowState.Maximized;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WindowState = FormWindowState.Normal;
|
|
||||||
|
|
||||||
if (mp.Border)
|
|
||||||
FormBorderStyle = FormBorderStyle.Sizable;
|
|
||||||
else
|
|
||||||
FormBorderStyle = FormBorderStyle.None;
|
|
||||||
|
|
||||||
SetFormPosAndSize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,20 +366,24 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
case 0x0201: // WM_LBUTTONDOWN
|
case 0x0201: // WM_LBUTTONDOWN
|
||||||
case 0x0202: // WM_LBUTTONUP
|
case 0x0202: // WM_LBUTTONUP
|
||||||
|
case 0x0207: // WM_MBUTTONDOWN
|
||||||
|
case 0x0208: // WM_MBUTTONUP
|
||||||
|
case 0x020A: // WM_MOUSEWHEEL
|
||||||
|
case 0x020C: // WM_XBUTTONUP
|
||||||
|
case 0x020B: // WM_XBUTTONDOWN
|
||||||
case 0x0100: // WM_KEYDOWN
|
case 0x0100: // WM_KEYDOWN
|
||||||
case 0x0101: // WM_KEYUP
|
case 0x0101: // WM_KEYUP
|
||||||
case 0x0104: // WM_SYSKEYDOWN
|
case 0x0104: // WM_SYSKEYDOWN
|
||||||
case 0x0105: // WM_SYSKEYUP
|
case 0x0105: // WM_SYSKEYUP
|
||||||
case 0x020A: // WM_MOUSEWHEEL
|
|
||||||
case 0x0207: // WM_MBUTTONDOWN
|
|
||||||
case 0x0208: // WM_MBUTTONUP
|
|
||||||
if (mp.WindowHandle != IntPtr.Zero)
|
if (mp.WindowHandle != IntPtr.Zero)
|
||||||
Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
|
Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||||
break;
|
break;
|
||||||
case 0x0200: // WM_MOUSEMOVE
|
case 0x0200: // WM_MOUSEMOVE
|
||||||
|
{
|
||||||
Point pos = PointToClient(Cursor.Position);
|
Point pos = PointToClient(Cursor.Position);
|
||||||
mp.command_string($"mouse {pos.X} {pos.Y}");
|
mp.command_string($"mouse {pos.X} {pos.Y}");
|
||||||
if (CursorHelp.IsPosDifferent(LastCursorPosChanged)) CursorHelp.Show();
|
if (CursorHelp.IsPosDifferent(LastCursorPosChanged)) CursorHelp.Show();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x2a3: // WM_MOUSELEAVE
|
case 0x2a3: // WM_MOUSELEAVE
|
||||||
mp.command_string("mouse 1 1"); // osc won't always auto hide
|
mp.command_string("mouse 1 1"); // osc won't always auto hide
|
||||||
@@ -363,7 +393,10 @@ namespace mpvnet
|
|||||||
Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
|
Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||||
break;
|
break;
|
||||||
case 0x203: // Native.WM.LBUTTONDBLCLK
|
case 0x203: // Native.WM.LBUTTONDBLCLK
|
||||||
if (!IsMouseInOSC()) mp.command_string("cycle fullscreen");
|
{
|
||||||
|
Point pos = PointToClient(Cursor.Position);
|
||||||
|
mp.command_string($"mouse {pos.X} {pos.Y} 0 double");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x02E0: // WM_DPICHANGED
|
case 0x02E0: // WM_DPICHANGED
|
||||||
if (IgnoreDpiChanged) break;
|
if (IgnoreDpiChanged) break;
|
||||||
@@ -463,23 +496,6 @@ namespace mpvnet
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnLoad(EventArgs e)
|
|
||||||
{
|
|
||||||
base.OnLoad(e);
|
|
||||||
mp.Init();
|
|
||||||
mp.observe_property_bool("fullscreen", PropChangeFullscreen);
|
|
||||||
mp.observe_property_bool("ontop", PropChangeOnTop);
|
|
||||||
mp.observe_property_bool("border", PropChangeBorder);
|
|
||||||
mp.observe_property_string("sid", PropChangeSid);
|
|
||||||
mp.observe_property_string("aid", PropChangeAid);
|
|
||||||
mp.observe_property_string("vid", PropChangeVid);
|
|
||||||
mp.observe_property_int("edition", PropChangeEdition);
|
|
||||||
mp.Shutdown += Shutdown;
|
|
||||||
mp.VideoSizeChanged += VideoSizeChanged;
|
|
||||||
mp.FileLoaded += FileLoaded;
|
|
||||||
mp.Idle += Idle;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnShown(EventArgs e)
|
protected override void OnShown(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnShown(e);
|
base.OnShown(e);
|
||||||
@@ -507,13 +523,20 @@ namespace mpvnet
|
|||||||
if (mp.IsLogoVisible) mp.ShowLogo();
|
if (mp.IsLogoVisible) mp.ShowLogo();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFormClosed(e);
|
base.OnFormClosing(e);
|
||||||
|
|
||||||
|
if (WindowState == FormWindowState.Normal)
|
||||||
|
{
|
||||||
|
RegHelp.SetObject(App.RegPath, "PosX", Left + Width / 2);
|
||||||
|
RegHelp.SetObject(App.RegPath, "PosY", Top + Height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
RegHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray());
|
RegHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray());
|
||||||
App.Exit();
|
App.Exit();
|
||||||
mp.commandv("quit");
|
mp.commandv("quit");
|
||||||
mp.AutoResetEvent.WaitOne(3000);
|
mp.ShutdownAutoResetEvent.WaitOne(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnMouseDown(MouseEventArgs e)
|
protected override void OnMouseDown(MouseEventArgs e)
|
||||||
|
|||||||
@@ -58,9 +58,10 @@ namespace mpvnet
|
|||||||
public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<bool>>>();
|
public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<bool>>>();
|
||||||
public static List<KeyValuePair<string, Action<int>>> IntPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<int>>>();
|
public static List<KeyValuePair<string, Action<int>>> IntPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<int>>>();
|
||||||
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>();
|
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>();
|
||||||
public static Size VideoSize { get; set; } = new Size(1920, 1080);
|
public static Size VideoSize { get; set; }
|
||||||
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
|
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
|
||||||
public static AutoResetEvent AutoResetEvent { get; set; } = new AutoResetEvent(false);
|
public static AutoResetEvent ShutdownAutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||||
|
public static AutoResetEvent VideoSizeAutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||||
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
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 List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
|
||||||
|
|
||||||
@@ -72,13 +73,29 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static bool Fullscreen { get; set; }
|
public static bool Fullscreen { get; set; }
|
||||||
public static bool Border { get; set; } = true;
|
public static bool Border { get; set; } = true;
|
||||||
public static bool RememberHeight { get; set; } = true;
|
|
||||||
|
|
||||||
public static int Screen { get; set; } = -1;
|
public static int Screen { get; set; } = -1;
|
||||||
public static int Edition { get; set; }
|
public static int Edition { get; set; }
|
||||||
|
|
||||||
public static float Autofit { get; set; } = 0.5f;
|
public static float Autofit { get; set; } = 0.5f;
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
LoadLibrary("mpv-1.dll");
|
||||||
|
Handle = mpv_create();
|
||||||
|
set_property_string("osc", "yes");
|
||||||
|
set_property_string("config", "yes");
|
||||||
|
set_property_string("wid", MainForm.Hwnd.ToString());
|
||||||
|
set_property_string("force-window", "yes");
|
||||||
|
set_property_string("input-media-keys", "yes");
|
||||||
|
mpv_initialize(Handle);
|
||||||
|
ShowLogo();
|
||||||
|
ProcessCommandLine();
|
||||||
|
Task.Run(() => { LoadScripts(); });
|
||||||
|
Task.Run(() => { Addon = new Addon(); });
|
||||||
|
Task.Run(() => { EventLoop(); });
|
||||||
|
}
|
||||||
|
|
||||||
public static void ProcessProperty(string name, string value)
|
public static void ProcessProperty(string name, string value)
|
||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
@@ -92,7 +109,6 @@ namespace mpvnet
|
|||||||
case "fullscreen": Fullscreen = value == "yes"; break;
|
case "fullscreen": Fullscreen = value == "yes"; break;
|
||||||
case "border": Border = value == "yes"; break;
|
case "border": Border = value == "yes"; break;
|
||||||
case "screen": Screen = Convert.ToInt32(value); break;
|
case "screen": Screen = Convert.ToInt32(value); break;
|
||||||
case "remember-height": RememberHeight = value == "yes"; break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,24 +177,6 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Init()
|
|
||||||
{
|
|
||||||
string dummy = ConfFolder;
|
|
||||||
LoadLibrary("mpv-1.dll");
|
|
||||||
Handle = mpv_create();
|
|
||||||
set_property_string("osc", "yes");
|
|
||||||
set_property_string("config", "yes");
|
|
||||||
set_property_string("wid", MainForm.Hwnd.ToString());
|
|
||||||
set_property_string("force-window", "yes");
|
|
||||||
set_property_string("input-media-keys", "yes");
|
|
||||||
mpv_initialize(Handle);
|
|
||||||
ShowLogo();
|
|
||||||
ProcessCommandLine();
|
|
||||||
Task.Run(() => { LoadScripts(); });
|
|
||||||
Task.Run(() => { Addon = new Addon(); });
|
|
||||||
Task.Run(() => { EventLoop(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void LoadScripts()
|
public static void LoadScripts()
|
||||||
{
|
{
|
||||||
string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts");
|
string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts");
|
||||||
@@ -222,7 +220,7 @@ namespace mpvnet
|
|||||||
case mpv_event_id.MPV_EVENT_SHUTDOWN:
|
case mpv_event_id.MPV_EVENT_SHUTDOWN:
|
||||||
Shutdown?.Invoke();
|
Shutdown?.Invoke();
|
||||||
WriteHistory(null);
|
WriteHistory(null);
|
||||||
AutoResetEvent.Set();
|
ShutdownAutoResetEvent.Set();
|
||||||
return;
|
return;
|
||||||
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
|
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
|
||||||
LogMessage?.Invoke();
|
LogMessage?.Invoke();
|
||||||
@@ -319,6 +317,8 @@ namespace mpvnet
|
|||||||
VideoSizeChanged?.Invoke();
|
VideoSizeChanged?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VideoSizeAutoResetEvent.Set();
|
||||||
|
|
||||||
Task.Run(new Action(() => ReadMetaData()));
|
Task.Run(new Action(() => ReadMetaData()));
|
||||||
break;
|
break;
|
||||||
case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE:
|
case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE:
|
||||||
@@ -516,6 +516,8 @@ namespace mpvnet
|
|||||||
|
|
||||||
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
|
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
|
||||||
|
|
||||||
|
if (files.Count == 0) VideoSizeAutoResetEvent.Set();
|
||||||
|
|
||||||
foreach (string i in args)
|
foreach (string i in args)
|
||||||
{
|
{
|
||||||
if (i.StartsWith("--"))
|
if (i.StartsWith("--"))
|
||||||
@@ -539,7 +541,7 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user