-
This commit is contained in:
@@ -191,7 +191,7 @@ namespace mpvnet
|
|||||||
MainForm.Instance.Invoke(new Action(() => {
|
MainForm.Instance.Invoke(new Action(() => {
|
||||||
string command = Microsoft.VisualBasic.Interaction.InputBox("Enter URL to be opened.");
|
string command = Microsoft.VisualBasic.Interaction.InputBox("Enter URL to be opened.");
|
||||||
if (string.IsNullOrEmpty(command)) return;
|
if (string.IsNullOrEmpty(command)) return;
|
||||||
mp.LoadURL(command);
|
mp.LoadFiles(command);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace mpvnet
|
|||||||
Point LastCursorPosChanged;
|
Point LastCursorPosChanged;
|
||||||
int LastCursorChangedTickCount;
|
int LastCursorChangedTickCount;
|
||||||
bool IgnoreDpiChanged = true;
|
bool IgnoreDpiChanged = true;
|
||||||
|
List<string> RecentFiles;
|
||||||
|
|
||||||
public string MpvNetDarkMode { get; set; } = "always";
|
public string MpvNetDarkMode { get; set; } = "always";
|
||||||
public bool MpvFullscreen { get; set; }
|
public bool MpvFullscreen { get; set; }
|
||||||
@@ -49,6 +50,12 @@ namespace mpvnet
|
|||||||
Hwnd = Handle;
|
Hwnd = Handle;
|
||||||
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
|
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
|
||||||
Text += " " + Application.ProductVersion;
|
Text += " " + Application.ProductVersion;
|
||||||
|
object recent = RegistryHelp.GetObject("HKCU\\Software\\" + Application.ProductName, "Recent");
|
||||||
|
|
||||||
|
if (recent is string[])
|
||||||
|
RecentFiles = new List<string>((string[])recent);
|
||||||
|
else
|
||||||
|
RecentFiles = new List<string>();
|
||||||
|
|
||||||
foreach (var i in mp.mpvConf)
|
foreach (var i in mp.mpvConf)
|
||||||
ProcessMpvProperty(i.Key, i.Value);
|
ProcessMpvProperty(i.Key, i.Value);
|
||||||
@@ -152,6 +159,21 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuItem recent = FindMenuItem("Recent");
|
||||||
|
|
||||||
|
if (recent != null)
|
||||||
|
{
|
||||||
|
recent.DropDownItems.Clear();
|
||||||
|
|
||||||
|
foreach (string path in RecentFiles)
|
||||||
|
MenuItem.Add(recent.DropDownItems, path, () => mp.LoadFiles(path));
|
||||||
|
|
||||||
|
recent.DropDownItems.Add(new ToolStripSeparator());
|
||||||
|
MenuItem mi = new MenuItem("Clear List");
|
||||||
|
mi.Action = () => RecentFiles.Clear();
|
||||||
|
recent.DropDownItems.Add(mi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
||||||
@@ -340,7 +362,14 @@ namespace mpvnet
|
|||||||
|
|
||||||
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
|
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
|
||||||
|
|
||||||
void mp_PlaybackRestart() => BeginInvoke(new Action(() => { Text = Path.GetFileName(mp.get_property_string("path")) + " - mpv.net " + Application.ProductVersion; }));
|
private void Mp_FileLoaded()
|
||||||
|
{
|
||||||
|
string path = mp.get_property_string("path");
|
||||||
|
BeginInvoke(new Action(() => { Text = Path.GetFileName(path) + " - mpv.net " + Application.ProductVersion; }));
|
||||||
|
if (RecentFiles.Contains(path)) RecentFiles.Remove(path);
|
||||||
|
RecentFiles.Insert(0, path);
|
||||||
|
if (RecentFiles.Count > 15) RecentFiles.RemoveAt(15);
|
||||||
|
}
|
||||||
|
|
||||||
void Mp_Idle() => BeginInvoke(new Action(() => { Text = "mpv.net " + Application.ProductVersion; }));
|
void Mp_Idle() => BeginInvoke(new Action(() => { Text = "mpv.net " + Application.ProductVersion; }));
|
||||||
|
|
||||||
@@ -455,7 +484,7 @@ namespace mpvnet
|
|||||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||||
mp.LoadFiles(e.Data.GetData(DataFormats.FileDrop) as String[]);
|
mp.LoadFiles(e.Data.GetData(DataFormats.FileDrop) as String[]);
|
||||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||||
mp.LoadURL(e.Data.GetData(DataFormats.Text).ToString());
|
mp.LoadFiles(e.Data.GetData(DataFormats.Text).ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnMouseDown(MouseEventArgs e)
|
protected override void OnMouseDown(MouseEventArgs e)
|
||||||
@@ -521,7 +550,7 @@ namespace mpvnet
|
|||||||
mp.observe_property_int("edition", mpPropChangeEdition);
|
mp.observe_property_int("edition", mpPropChangeEdition);
|
||||||
mp.Shutdown += mp_Shutdown;
|
mp.Shutdown += mp_Shutdown;
|
||||||
mp.VideoSizeChanged += mp_VideoSizeChanged;
|
mp.VideoSizeChanged += mp_VideoSizeChanged;
|
||||||
mp.PlaybackRestart += mp_PlaybackRestart;
|
mp.FileLoaded += Mp_FileLoaded;
|
||||||
mp.Idle += Mp_Idle;
|
mp.Idle += Mp_Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,6 +581,7 @@ namespace mpvnet
|
|||||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
protected override void OnFormClosed(FormClosedEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFormClosed(e);
|
base.OnFormClosed(e);
|
||||||
|
RegistryHelp.SetObject("HKCU\\Software\\" + Application.ProductName, "Recent", RecentFiles.ToArray());
|
||||||
mp.commandv("quit");
|
mp.commandv("quit");
|
||||||
mp.AutoResetEvent.WaitOne(3000);
|
mp.AutoResetEvent.WaitOne(3000);
|
||||||
}
|
}
|
||||||
@@ -572,12 +602,12 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
string clipboard = Clipboard.GetText();
|
string clipboard = Clipboard.GetText();
|
||||||
|
|
||||||
if (clipboard.StartsWith("https://www.youtube.com/watch?") && RegistryHelp.GetValue("HKCU\\Software\\" + Application.ProductName, "LastYouTubeURL") != clipboard && Visible)
|
if (clipboard.StartsWith("https://www.youtube.com/watch?") && RegistryHelp.GetString("HKCU\\Software\\" + Application.ProductName, "LastYouTubeURL") != clipboard && Visible)
|
||||||
{
|
{
|
||||||
RegistryHelp.SetValue("HKCU\\Software\\" + Application.ProductName, "LastYouTubeURL", clipboard);
|
RegistryHelp.SetObject("HKCU\\Software\\" + Application.ProductName, "LastYouTubeURL", clipboard);
|
||||||
|
|
||||||
if (Msg.ShowQuestion("Play YouTube URL?", clipboard) == MsgResult.OK)
|
if (Msg.ShowQuestion("Play YouTube URL?", clipboard) == MsgResult.OK)
|
||||||
mp.LoadURL(clipboard);
|
mp.LoadFiles(clipboard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,11 +61,6 @@ public class MenuItem : ToolStripMenuItem
|
|||||||
base.OnClick(e);
|
base.OnClick(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MenuItem Add<T>(ToolStripItemCollection items, string path, Action<T> action, T value)
|
|
||||||
{
|
|
||||||
return Add(items, path, () => action(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MenuItem Add(ToolStripItemCollection items, string path, Action action)
|
public static MenuItem Add(ToolStripItemCollection items, string path, Action action)
|
||||||
{
|
{
|
||||||
string[] a = path.Split(new[] { " > ", " | " }, StringSplitOptions.RemoveEmptyEntries);
|
string[] a = path.Split(new[] { " > ", " | " }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|||||||
@@ -83,26 +83,26 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
Types = types;
|
Types = types;
|
||||||
|
|
||||||
RegistryHelp.SetValue(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename, null, ExePath);
|
RegistryHelp.SetObject(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename, null, ExePath);
|
||||||
RegistryHelp.SetValue($"HKCR\\Applications\\{ExeFilename}", "FriendlyAppName", "mpv.net media player");
|
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}", "FriendlyAppName", "mpv.net media player");
|
||||||
RegistryHelp.SetValue($"HKCR\\Applications\\{ExeFilename}\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
|
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
|
||||||
RegistryHelp.SetValue(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationDescription", "mpv.net media player");
|
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationDescription", "mpv.net media player");
|
||||||
RegistryHelp.SetValue(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationName", "mpv.net");
|
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationName", "mpv.net");
|
||||||
RegistryHelp.SetValue($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}", null, "");
|
RegistryHelp.SetObject($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}", null, "");
|
||||||
RegistryHelp.SetValue($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}", null, "");
|
RegistryHelp.SetObject($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}", null, "");
|
||||||
|
|
||||||
foreach (string ext in Types)
|
foreach (string ext in Types)
|
||||||
{
|
{
|
||||||
RegistryHelp.SetValue($"HKCR\\Applications\\{ExeFilename}\\SupportedTypes", "." + ext, "");
|
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\SupportedTypes", "." + ext, "");
|
||||||
RegistryHelp.SetValue($"HKCR\\" + "." + ext, null, ExeFilenameNoExt + "." + ext);
|
RegistryHelp.SetObject($"HKCR\\" + "." + ext, null, ExeFilenameNoExt + "." + ext);
|
||||||
RegistryHelp.SetValue($"HKCR\\" + "." + ext + "\\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, "");
|
RegistryHelp.SetObject($"HKCR\\" + "." + ext + "\\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, "");
|
||||||
if (VideoTypes.Contains(ext))
|
if (VideoTypes.Contains(ext))
|
||||||
RegistryHelp.SetValue($"HKCR\\" + "." + ext, "PerceivedType", "video");
|
RegistryHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "video");
|
||||||
if (AudioTypes.Contains(ext))
|
if (AudioTypes.Contains(ext))
|
||||||
RegistryHelp.SetValue($"HKCR\\" + "." + ext, "PerceivedType", "audio");
|
RegistryHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "audio");
|
||||||
RegistryHelp.SetValue($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open", null, "Play with " + Application.ProductName);
|
RegistryHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open", null, "Play with " + Application.ProductName);
|
||||||
RegistryHelp.SetValue($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
|
RegistryHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
|
||||||
RegistryHelp.SetValue(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext);
|
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,19 +127,26 @@ namespace mpvnet
|
|||||||
|
|
||||||
public class RegistryHelp
|
public class RegistryHelp
|
||||||
{
|
{
|
||||||
public static void SetValue(string path, string name, string value)
|
public static void SetObject(string path, string name, object value)
|
||||||
{
|
{
|
||||||
using (RegistryKey rk = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))
|
using (RegistryKey rk = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))
|
||||||
rk.SetValue(name, value);
|
rk.SetValue(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetValue(string path, string name)
|
public static string GetString(string path, string name)
|
||||||
|
{
|
||||||
|
object val = GetObject(path, name);
|
||||||
|
if (val == null || !(val is string)) return "";
|
||||||
|
return val.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object GetObject(string path, string name)
|
||||||
{
|
{
|
||||||
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, "").ToString();
|
return rk.GetValue(name, "");
|
||||||
else
|
else
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RemoveKey(string path)
|
public static void RemoveKey(string path)
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
_ ignore #menu: Open > -
|
_ ignore #menu: Open > -
|
||||||
Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files...
|
Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files...
|
||||||
Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files...
|
Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files...
|
||||||
|
_ ignore #menu: Open > -
|
||||||
|
_ ignore #menu: Open > Recent
|
||||||
|
|
||||||
_ ignore #menu: -
|
_ ignore #menu: -
|
||||||
Space cycle pause #menu: Play/Pause
|
Space cycle pause #menu: Play/Pause
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace mpvnet
|
|||||||
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
|
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
|
||||||
LoadSettings(MpvSettingsDefinitions, MpvConf);
|
LoadSettings(MpvSettingsDefinitions, MpvConf);
|
||||||
LoadSettings(MpvNetSettingsDefinitions, MpvNetConf);
|
LoadSettings(MpvNetSettingsDefinitions, MpvNetConf);
|
||||||
SearchControl.Text = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\mpv.net", "conf editor search", "");
|
SearchControl.Text = RegistryHelp.GetString(@"HKCU\Software\mpv.net", "config editor search");
|
||||||
|
|
||||||
if (App.IsDarkMode)
|
if (App.IsDarkMode)
|
||||||
{
|
{
|
||||||
@@ -133,7 +133,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
WriteToDisk();
|
WriteToDisk();
|
||||||
Registry.SetValue(@"HKEY_CURRENT_USER\Software\mpv.net", "conf editor search", SearchControl.Text);
|
RegistryHelp.SetObject(@"HKCU\Software\mpv.net", "config editor search", SearchControl.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteToDisk()
|
void WriteToDisk()
|
||||||
|
|||||||
@@ -522,8 +522,6 @@ namespace mpvnet
|
|||||||
foreach (string i in args)
|
foreach (string i in args)
|
||||||
if (!i.StartsWith("--") && File.Exists(i))
|
if (!i.StartsWith("--") && File.Exists(i))
|
||||||
mp.commandv("loadfile", i, "append");
|
mp.commandv("loadfile", i, "append");
|
||||||
else if (!i.StartsWith("--") && i.StartsWith("http"))
|
|
||||||
mp.LoadURL(i);
|
|
||||||
|
|
||||||
mp.set_property_string("playlist-pos", "0");
|
mp.set_property_string("playlist-pos", "0");
|
||||||
|
|
||||||
@@ -543,16 +541,7 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadURL(string url)
|
public static void LoadFiles(params string[] files)
|
||||||
{
|
|
||||||
int count = mp.get_property_int("playlist-count");
|
|
||||||
mp.commandv("loadfile", url, "append");
|
|
||||||
mp.set_property_int("playlist-pos", count);
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
mp.commandv("playlist-remove", "0");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void LoadFiles(string[] files)
|
|
||||||
{
|
{
|
||||||
int count = mp.get_property_int("playlist-count");
|
int count = mp.get_property_int("playlist-count");
|
||||||
|
|
||||||
@@ -571,14 +560,13 @@ namespace mpvnet
|
|||||||
|
|
||||||
static void LoadFolder()
|
static void LoadFolder()
|
||||||
{
|
{
|
||||||
if (WasFolderLoaded)
|
if (WasFolderLoaded) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (get_property_int("playlist-count") == 1)
|
if (get_property_int("playlist-count") == 1)
|
||||||
{
|
{
|
||||||
string[] types = "264 265 3gp aac ac3 avc avi avs bmp divx dts dtshd dtshr dtsma eac3 evo flac flv h264 h265 hevc hvc jpg jpeg m2t m2ts m2v m4a m4v mka mkv mlp mov mp2 mp3 mp4 mpa mpeg mpg mpv mts ogg ogm opus pcm png pva raw rmvb thd thd+ac3 true-hd truehd ts vdr vob vpy w64 wav webm wmv y4m".Split(' ');
|
|
||||||
string path = get_property_string("path");
|
string path = get_property_string("path");
|
||||||
if (!Directory.Exists(Path.GetDirectoryName(path))) return;
|
if (!Directory.Exists(Path.GetDirectoryName(path))) return;
|
||||||
|
string[] types = "264 265 3gp aac ac3 avc avi avs bmp divx dts dtshd dtshr dtsma eac3 evo flac flv h264 h265 hevc hvc jpg jpeg m2t m2ts m2v m4a m4v mka mkv mlp mov mp2 mp3 mp4 mpa mpeg mpg mpv mts ogg ogm opus pcm png pva raw rmvb thd thd+ac3 true-hd truehd ts vdr vob vpy w64 wav webm wmv y4m".Split(' ');
|
||||||
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
|
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
|
||||||
files = files.Where((file) => types.Contains(Path.GetExtension(file).TrimStart(".".ToCharArray()).ToLower())).ToList();
|
files = files.Where((file) => types.Contains(Path.GetExtension(file).TrimStart(".".ToCharArray()).ToLower())).ToList();
|
||||||
files.Sort(new StringLogicalComparer());
|
files.Sort(new StringLogicalComparer());
|
||||||
|
|||||||
Reference in New Issue
Block a user