new setting remember-volume added
This commit is contained in:
@@ -13,9 +13,8 @@
|
|||||||
- 'Tools > Manage File Associations' was replaced by 'Tools > OS Setup',
|
- 'Tools > Manage File Associations' was replaced by 'Tools > OS Setup',
|
||||||
it has now a feature to add and remove mpv.net to and from the Path
|
it has now a feature to add and remove mpv.net to and from the Path
|
||||||
environment variable and the OS default apps settings can be opened (Win 10 only)
|
environment variable and the OS default apps settings can be opened (Win 10 only)
|
||||||
- startup folder and config folder beeing identical is no longer
|
- startup folder and config folder beeing identical is no longer a supported scenaria
|
||||||
a supported scenaria because it's a brain-dead idea
|
- error messages are shown when unknown scripts and extensions are found in the startup folder
|
||||||
- Error messages are shown when unknown scripts and extensions are found in the startup folder
|
|
||||||
because user scripts and extensions are supposed to be located in the config folder instead
|
because user scripts and extensions are supposed to be located in the config folder instead
|
||||||
|
|
||||||
### 5.0
|
### 5.0
|
||||||
@@ -99,6 +98,10 @@
|
|||||||
the task bar because this is the WinForms default behavier. This
|
the task bar because this is the WinForms default behavier. This
|
||||||
was fixed by calling Spy++ to the rescue and adding WS_MINIMIZEBOX
|
was fixed by calling Spy++ to the rescue and adding WS_MINIMIZEBOX
|
||||||
in CreateParams
|
in CreateParams
|
||||||
|
- changing from maximized to fullscreen did not work
|
||||||
|
- the search field in the config editor was not always remembered
|
||||||
|
- new setting remember-volume added, saves volume and mute on exit
|
||||||
|
and restores it on start.
|
||||||
|
|
||||||
### 4.6
|
### 4.6
|
||||||
|
|
||||||
|
|||||||
125
mpv.net/Misc/App.cs
Normal file
125
mpv.net/Misc/App.cs
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace mpvnet
|
||||||
|
{
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
|
||||||
|
public static string ConfPath { get; } = mp.ConfigFolder + "\\mpvnet.conf";
|
||||||
|
public static string DarkMode { get; set; } = "always";
|
||||||
|
public static string ProcessInstance { get; set; } = "single";
|
||||||
|
public static string DarkColor { get; set; }
|
||||||
|
public static string LightColor { get; set; }
|
||||||
|
|
||||||
|
public static string[] VideoTypes { get; } = "264 265 asf avc avi avs flv h264 h265 hevc m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm webm wmv y4m".Split(' ');
|
||||||
|
public static string[] 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".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 bool RememberHeight { get; set; } = true;
|
||||||
|
public static bool RememberPosition { get; set; }
|
||||||
|
public static bool DebugMode { get; set; }
|
||||||
|
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
|
||||||
|
public static bool RememberVolume { get; set; }
|
||||||
|
|
||||||
|
public static int StartThreshold { get; set; } = 1500;
|
||||||
|
|
||||||
|
public static bool IsDarkMode {
|
||||||
|
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
string dummy = mp.ConfigFolder;
|
||||||
|
var dummy2 = mp.Conf;
|
||||||
|
|
||||||
|
foreach (var i in Conf)
|
||||||
|
ProcessProperty(i.Key, i.Value);
|
||||||
|
|
||||||
|
if (App.DebugMode)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string filePath = mp.ConfigFolder + "\\mpvnet-debug.log";
|
||||||
|
if (File.Exists(filePath)) File.Delete(filePath);
|
||||||
|
Trace.Listeners.Add(new TextWriterTraceListener(filePath));
|
||||||
|
Trace.AutoFlush = true;
|
||||||
|
//if (App.DebugMode) Trace.WriteLine("");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Msg.ShowException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.Shutdown += Shutdown;
|
||||||
|
mp.Initialized += Initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Initialized()
|
||||||
|
{
|
||||||
|
if (RememberVolume)
|
||||||
|
{
|
||||||
|
mp.set_property_int("volume", RegHelp.GetInt(App.RegPath, "Volume"));
|
||||||
|
mp.set_property_string("mute", RegHelp.GetString(App.RegPath, "Mute"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Shutdown()
|
||||||
|
{
|
||||||
|
if (RememberVolume)
|
||||||
|
{
|
||||||
|
RegHelp.SetObject(App.RegPath, "Volume", mp.get_property_int("volume"));
|
||||||
|
RegHelp.SetObject(App.RegPath, "Mute", mp.get_property_string("mute"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Dictionary<string, string> _Conf;
|
||||||
|
|
||||||
|
public static Dictionary<string, string> Conf {
|
||||||
|
get {
|
||||||
|
if (_Conf == null)
|
||||||
|
{
|
||||||
|
_Conf = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
if (File.Exists(ConfPath))
|
||||||
|
foreach (string i in File.ReadAllLines(ConfPath))
|
||||||
|
if (i.Contains("=") && !i.StartsWith("#"))
|
||||||
|
_Conf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
||||||
|
}
|
||||||
|
return _Conf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UnknownModule(string path)
|
||||||
|
{
|
||||||
|
Msg.ShowError("Failed to load script or extension", "Only scripts and extensions that ship with mpv.net are allowed in <startup>\\scripts or <startup>\\extensions.\n\nUser scripts or extensions have to use <config folder>\\scripts or <config folder>\\extensions.\n\nNever copy a new mpv.net version over a old mpv.net version.\n\nNever install a new mpv.net version on top of a old mpv.net version.\n\n" + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ProcessProperty(string name, string value)
|
||||||
|
{
|
||||||
|
switch (name) // return true instead of break!
|
||||||
|
{
|
||||||
|
case "remember-position": RememberPosition = value == "yes"; return true;
|
||||||
|
case "start-size": RememberHeight = value == "previous"; return true;
|
||||||
|
case "process-instance": ProcessInstance = value; return true;
|
||||||
|
case "dark-mode": DarkMode = value; return true;
|
||||||
|
case "debug-mode": DebugMode = value == "yes"; return true;
|
||||||
|
case "dark-color": DarkColor = value.Trim('\'', '"'); return true;
|
||||||
|
case "light-color": LightColor = value.Trim('\'', '"'); return true;
|
||||||
|
case "url-whitelist": UrlWhitelist = value.Split(' ', ',', ';'); return true;
|
||||||
|
case "remember-volume": RememberVolume = value == "yes"; return true;
|
||||||
|
case "start-threshold":
|
||||||
|
int.TryParse(value, out int result);
|
||||||
|
StartThreshold = result;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -16,100 +15,6 @@ using Microsoft.Win32;
|
|||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
public class App
|
|
||||||
{
|
|
||||||
public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
|
|
||||||
public static string ConfPath { get; } = mp.ConfigFolder + "\\mpvnet.conf";
|
|
||||||
public static string DarkMode { get; set; } = "always";
|
|
||||||
public static string ProcessInstance { get; set; } = "single";
|
|
||||||
public static string DarkColor { get; set; }
|
|
||||||
public static string LightColor { get; set; }
|
|
||||||
|
|
||||||
public static string[] VideoTypes { get; } = "264 265 asf avc avi avs flv h264 h265 hevc m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm webm wmv y4m".Split(' ');
|
|
||||||
public static string[] 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".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 bool RememberHeight { get; set; } = true;
|
|
||||||
public static bool RememberPosition { get; set; }
|
|
||||||
public static bool DebugMode { get; set; }
|
|
||||||
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
|
|
||||||
|
|
||||||
public static int StartThreshold { get; set; } = 1500;
|
|
||||||
|
|
||||||
public static bool IsDarkMode {
|
|
||||||
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Init()
|
|
||||||
{
|
|
||||||
string dummy = mp.ConfigFolder;
|
|
||||||
var dummy2 = mp.Conf;
|
|
||||||
|
|
||||||
foreach (var i in Conf)
|
|
||||||
ProcessProperty(i.Key, i.Value);
|
|
||||||
|
|
||||||
if (App.DebugMode)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string filePath = mp.ConfigFolder + "\\mpvnet-debug.log";
|
|
||||||
if (File.Exists(filePath)) File.Delete(filePath);
|
|
||||||
Trace.Listeners.Add(new TextWriterTraceListener(filePath));
|
|
||||||
Trace.AutoFlush = true;
|
|
||||||
//if (App.DebugMode) Trace.WriteLine("");
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Msg.ShowException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Dictionary<string, string> _Conf;
|
|
||||||
|
|
||||||
public static Dictionary<string, string> Conf {
|
|
||||||
get {
|
|
||||||
if (_Conf == null)
|
|
||||||
{
|
|
||||||
_Conf = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
if (File.Exists(ConfPath))
|
|
||||||
foreach (string i in File.ReadAllLines(ConfPath))
|
|
||||||
if (i.Contains("=") && !i.StartsWith("#"))
|
|
||||||
_Conf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
|
||||||
}
|
|
||||||
return _Conf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UnknownModule(string path)
|
|
||||||
{
|
|
||||||
Msg.ShowError("Failed to load script or extension", "Only scripts and extensions that ship with mpv.net are allowed in <startup>\\scripts or <startup>\\extensions.\n\nUser scripts or extensions have to use <config folder>\\scripts or <config folder>\\extensions.\n\nNever copy a new mpv.net version over a old mpv.net version.\n\nNever install a new mpv.net version on top of a old mpv.net version.\n\n" + path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ProcessProperty(string name, string value)
|
|
||||||
{
|
|
||||||
switch (name) // return true instead of break!
|
|
||||||
{
|
|
||||||
case "remember-position": RememberPosition = value == "yes"; return true;
|
|
||||||
case "start-size": RememberHeight = value == "previous"; return true;
|
|
||||||
case "process-instance": ProcessInstance = value; return true;
|
|
||||||
case "dark-mode": DarkMode = value; return true;
|
|
||||||
case "debug-mode": DebugMode = value == "yes"; return true;
|
|
||||||
case "dark-color": DarkColor = value.Trim('\'', '"'); return true;
|
|
||||||
case "light-color": LightColor = value.Trim('\'', '"'); return true;
|
|
||||||
case "url-whitelist": UrlWhitelist = value.Split(' ', ',', ';'); return true;
|
|
||||||
case "start-threshold":
|
|
||||||
int.TryParse(value, out int result);
|
|
||||||
StartThreshold = result;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Sys
|
public class Sys
|
||||||
{
|
{
|
||||||
public static bool IsDarkTheme {
|
public static bool IsDarkTheme {
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
|
input-ar-delay = 500
|
||||||
# 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-rate = 20
|
input-ar-rate = 20
|
||||||
volume = 50
|
volume = 50
|
||||||
hwdec = yes
|
hwdec = yes
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ help = "Threshold in milliseconds to wait for libmpv returning the video resolut
|
|||||||
name = "remember-position"
|
name = "remember-position"
|
||||||
default = "no"
|
default = "no"
|
||||||
filter = "Screen"
|
filter = "Screen"
|
||||||
help = "Setting to save the window position on exit. (mpv.net specific setting)"
|
help = "Save the window position on exit. (mpv.net specific setting)"
|
||||||
|
options = [{ name = "yes" },
|
||||||
|
{ name = "no" }]
|
||||||
|
|
||||||
|
[[settings]]
|
||||||
|
name = "remember-volume"
|
||||||
|
default = "no"
|
||||||
|
filter = "Audio"
|
||||||
|
help = "Save volume and mute on exit and restore it on start. (mpv.net specific setting)"
|
||||||
options = [{ name = "yes" },
|
options = [{ name = "yes" },
|
||||||
{ name = "no" }]
|
{ name = "no" }]
|
||||||
@@ -29,7 +29,7 @@ namespace mpvnet
|
|||||||
LoadSettings(NetSettingsDefinitions, NetConf);
|
LoadSettings(NetSettingsDefinitions, NetConf);
|
||||||
InitialContent = GetContent(mp.ConfPath, Conf, SettingsDefinitions) +
|
InitialContent = GetContent(mp.ConfPath, Conf, SettingsDefinitions) +
|
||||||
GetContent(App.ConfPath, NetConf, NetSettingsDefinitions);
|
GetContent(App.ConfPath, NetConf, NetSettingsDefinitions);
|
||||||
SearchControl.Text = RegHelp.GetString(App.RegPath, "config editor search");
|
SearchControl.Text = RegHelp.GetString(App.RegPath, "ConfigEditorSearch");
|
||||||
|
|
||||||
if (App.IsDarkMode)
|
if (App.IsDarkMode)
|
||||||
{
|
{
|
||||||
@@ -124,14 +124,13 @@ namespace mpvnet
|
|||||||
protected override void OnClosed(EventArgs e)
|
protected override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
|
RegHelp.SetObject(App.RegPath, "ConfigEditorSearch", SearchControl.Text);
|
||||||
string content = GetContent(mp.ConfPath, Conf, SettingsDefinitions);
|
string content = GetContent(mp.ConfPath, Conf, SettingsDefinitions);
|
||||||
string netContent = GetContent(App.ConfPath, NetConf, NetSettingsDefinitions);
|
string netContent = GetContent(App.ConfPath, NetConf, NetSettingsDefinitions);
|
||||||
if (InitialContent == content + netContent) return;
|
if (InitialContent == content + netContent) return;
|
||||||
string header = "\r\n# manual: https://mpv.io/manual/master/\r\n\r\n# defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt\r\n\r\n";
|
File.WriteAllText(mp.ConfPath, content);
|
||||||
File.WriteAllText(mp.ConfPath, header + content);
|
|
||||||
File.WriteAllText(App.ConfPath, netContent);
|
File.WriteAllText(App.ConfPath, netContent);
|
||||||
Msg.Show("Changes will be available on next mpv.net startup.");
|
Msg.Show("Changes will be available on next mpv.net startup.");
|
||||||
RegHelp.SetObject(App.RegPath, "config editor search", SearchControl.Text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetContent(string filePath, Dictionary<string, string> confSettings, List<SettingBase> settings)
|
string GetContent(string filePath, Dictionary<string, string> confSettings, List<SettingBase> settings)
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ namespace mpvnet
|
|||||||
mp.VideoSizeChanged += VideoSizeChanged;
|
mp.VideoSizeChanged += VideoSizeChanged;
|
||||||
mp.FileLoaded += FileLoaded;
|
mp.FileLoaded += FileLoaded;
|
||||||
mp.Idle += Idle;
|
mp.Idle += Idle;
|
||||||
mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
|
|
||||||
if (Height < FontHeight * 4) SetFormPosAndSize();
|
|
||||||
mp.observe_property_bool("fullscreen", PropChangeFullscreen);
|
mp.observe_property_bool("fullscreen", PropChangeFullscreen);
|
||||||
mp.observe_property_bool("ontop", PropChangeOnTop);
|
mp.observe_property_bool("ontop", PropChangeOnTop);
|
||||||
mp.observe_property_bool("border", PropChangeBorder);
|
mp.observe_property_bool("border", PropChangeBorder);
|
||||||
@@ -82,6 +81,9 @@ namespace mpvnet
|
|||||||
mp.observe_property_string("aid", PropChangeAid);
|
mp.observe_property_string("aid", PropChangeAid);
|
||||||
mp.observe_property_string("vid", PropChangeVid);
|
mp.observe_property_string("vid", PropChangeVid);
|
||||||
mp.observe_property_int("edition", PropChangeEdition);
|
mp.observe_property_int("edition", PropChangeEdition);
|
||||||
|
|
||||||
|
mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
|
||||||
|
if (Height < FontHeight * 4) SetFormPosAndSize();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -308,7 +310,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
if (WindowState != FormWindowState.Maximized)
|
if (WindowState != FormWindowState.Maximized || FormBorderStyle != FormBorderStyle.None)
|
||||||
{
|
{
|
||||||
FormBorderStyle = FormBorderStyle.None;
|
FormBorderStyle = FormBorderStyle.None;
|
||||||
WindowState = FormWindowState.Maximized;
|
WindowState = FormWindowState.Maximized;
|
||||||
@@ -465,22 +467,6 @@ namespace mpvnet
|
|||||||
base.WndProc(ref m);
|
base.WndProc(ref m);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDragEnter(DragEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnDragEnter(e);
|
|
||||||
if (e.Data.GetDataPresent(DataFormats.FileDrop) || e.Data.GetDataPresent(DataFormats.Text))
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnDragDrop(DragEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnDragDrop(e);
|
|
||||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
|
||||||
mp.Load(e.Data.GetData(DataFormats.FileDrop) as String[], true, Control.ModifierKeys.HasFlag(Keys.Control));
|
|
||||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
|
||||||
mp.Load(new[] { e.Data.GetData(DataFormats.Text).ToString() }, true, Control.ModifierKeys.HasFlag(Keys.Control));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Timer_Tick(object sender, EventArgs e)
|
void Timer_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
|
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
|
||||||
@@ -586,6 +572,22 @@ namespace mpvnet
|
|||||||
mp.commandv("quit");
|
mp.commandv("quit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnDragEnter(DragEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDragEnter(e);
|
||||||
|
if (e.Data.GetDataPresent(DataFormats.FileDrop) || e.Data.GetDataPresent(DataFormats.Text))
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDragDrop(DragEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDragDrop(e);
|
||||||
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||||
|
mp.Load(e.Data.GetData(DataFormats.FileDrop) as String[], true, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||||
|
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||||
|
mp.Load(new[] { e.Data.GetData(DataFormats.Text).ToString() }, true, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnLostFocus(EventArgs e)
|
protected override void OnLostFocus(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnLostFocus(e);
|
base.OnLostFocus(e);
|
||||||
|
|||||||
@@ -114,6 +114,7 @@
|
|||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Misc\App.cs" />
|
||||||
<Compile Include="Misc\Extension.cs" />
|
<Compile Include="Misc\Extension.cs" />
|
||||||
<Page Include="Controls\SearchTextBoxUserControl.xaml">
|
<Page Include="Controls\SearchTextBoxUserControl.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ namespace mpvnet
|
|||||||
public static event Action QueueOverflow; // MPV_EVENT_QUEUE_OVERFLOW
|
public static event Action QueueOverflow; // MPV_EVENT_QUEUE_OVERFLOW
|
||||||
public static event Action Hook; // MPV_EVENT_HOOK
|
public static event Action Hook; // MPV_EVENT_HOOK
|
||||||
|
|
||||||
|
public static event Action Initialized;
|
||||||
|
|
||||||
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 Extension Extension { get; set; }
|
||||||
@@ -77,7 +79,7 @@ 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 int Screen { get; set; } = -1;
|
public static int Screen { get; set; } = -1;
|
||||||
public static int Edition { get; set; }
|
public static int Edition { get; set; }
|
||||||
|
|
||||||
@@ -89,6 +91,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
LoadLibrary("mpv-1.dll");
|
LoadLibrary("mpv-1.dll");
|
||||||
Handle = mpv_create();
|
Handle = mpv_create();
|
||||||
|
Task.Run(() => { EventLoop(); });
|
||||||
|
|
||||||
if (App.IsStartedFromTerminal)
|
if (App.IsStartedFromTerminal)
|
||||||
{
|
{
|
||||||
@@ -96,17 +99,17 @@ namespace mpvnet
|
|||||||
set_property_string("msg-level", "osd/libass=fatal");
|
set_property_string("msg-level", "osd/libass=fatal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_property_string("wid", MainForm.Hwnd.ToString());
|
||||||
set_property_string("config-dir", ConfigFolder);
|
set_property_string("config-dir", ConfigFolder);
|
||||||
set_property_string("osc", "yes");
|
set_property_string("osc", "yes");
|
||||||
set_property_string("config", "yes");
|
set_property_string("config", "yes");
|
||||||
set_property_string("wid", MainForm.Hwnd.ToString());
|
|
||||||
set_property_string("force-window", "yes");
|
set_property_string("force-window", "yes");
|
||||||
set_property_string("input-media-keys", "yes");
|
set_property_string("input-media-keys", "yes");
|
||||||
mpv_initialize(Handle);
|
mpv_initialize(Handle);
|
||||||
|
Initialized?.Invoke();
|
||||||
ShowLogo();
|
ShowLogo();
|
||||||
LoadMpvScripts();
|
LoadMpvScripts();
|
||||||
ProcessCommandLine();
|
ProcessCommandLine();
|
||||||
Task.Run(() => { EventLoop(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ProcessProperty(string name, string value)
|
public static void ProcessProperty(string name, string value)
|
||||||
@@ -556,7 +559,7 @@ namespace mpvnet
|
|||||||
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action));
|
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void ProcessCommandLine()
|
public static void ProcessCommandLine()
|
||||||
{
|
{
|
||||||
var args = Environment.GetCommandLineArgs().Skip(1);
|
var args = Environment.GetCommandLineArgs().Skip(1);
|
||||||
List<string> files = new List<string>();
|
List<string> files = new List<string>();
|
||||||
|
|||||||
Reference in New Issue
Block a user