This commit is contained in:
Frank Skare
2019-06-24 07:52:30 +02:00
parent e5c9df31e4
commit 63f064ba1c
15 changed files with 131 additions and 125 deletions

View File

@@ -1,3 +1,12 @@
###
- clipboard-monitoring was replaced by url-whitelist:
Domain whitelist to monitor the clipboard for URLs to play.
Default: youtube ard zdf
- some settings like colors didn't work because enclosing quotes were missing
- the playlist is never cleared whenever the control key is down but
files and URLs are appended instead
### 4.3.1 ### 4.3.1
- there was a old bug setting the screen property - there was a old bug setting the screen property

View File

@@ -45,11 +45,11 @@ namespace DynamicGUI
optionSetting.Options.Add(opt); optionSetting.Options.Add(opt);
} }
} }
else if (setting["default"].IsString) else
{ {
StringSetting stringSetting = new StringSetting(); StringSetting stringSetting = new StringSetting();
baseSetting = stringSetting; baseSetting = stringSetting;
stringSetting.Default = setting["default"]; stringSetting.Default = setting.HasKey("default") ? setting["default"].ToString() : "";
} }
baseSetting.Name = setting["name"]; baseSetting.Name = setting["name"];

View File

@@ -64,7 +64,8 @@ namespace DynamicGUI
{ {
d.FullOpen = true; d.FullOpen = true;
try { try {
d.Color = System.Drawing.ColorTranslator.FromHtml(ValueTextBox.Text); Color col = GetColor(ValueTextBox.Text);
d.Color = System.Drawing.Color.FromArgb(col.A, col.R, col.G, col.B);
} catch { } } catch { }
if (d.ShowDialog() == WinForms.DialogResult.OK) if (d.ShowDialog() == WinForms.DialogResult.OK)
ValueTextBox.Text = System.Drawing.ColorTranslator.ToHtml(d.Color); ValueTextBox.Text = System.Drawing.ColorTranslator.ToHtml(d.Color);
@@ -75,29 +76,31 @@ namespace DynamicGUI
private void ValueTextBox_TextChanged(object sender, TextChangedEventArgs e) => Update(); private void ValueTextBox_TextChanged(object sender, TextChangedEventArgs e) => Update();
Color GetColor(string value)
{
if (value.Contains("/"))
{
string[] a = value.Split('/');
if (a.Length == 3)
return Color.FromRgb(ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
else if (a.Length == 4)
return Color.FromArgb(ToByte(a[3]), ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
}
return (Color)ColorConverter.ConvertFromString(value);
Byte ToByte(string val) => Convert.ToByte(Convert.ToSingle(val, CultureInfo.InvariantCulture) * 255);
}
public void Update() public void Update()
{ {
if (StringSetting.Type == "color") if (StringSetting.Type == "color")
{ {
Color c = Colors.Transparent; Color c = Colors.Transparent;
if (ValueTextBox.Text != "") if (ValueTextBox.Text != "") try { c = GetColor(ValueTextBox.Text); } catch {}
{
try {
if (ValueTextBox.Text.Contains("/"))
{
string[] a = ValueTextBox.Text.Split('/');
if (a.Length == 3)
c = Color.FromRgb(ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
else if (a.Length == 4)
c = Color.FromArgb(ToByte(a[3]), ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
}
else
c = (Color)ColorConverter.ConvertFromString(ValueTextBox.Text);
} catch {}
}
ValueTextBox.Background = new SolidColorBrush(c); ValueTextBox.Background = new SolidColorBrush(c);
} }
Byte ToByte(string val) => Convert.ToByte(Convert.ToSingle(val, CultureInfo.InvariantCulture) * 255);
} }
} }
} }

View File

@@ -48,7 +48,7 @@ namespace mpvnet
MainForm.Instance.Invoke(new Action(() => { MainForm.Instance.Invoke(new Action(() => {
using (var d = new OpenFileDialog() { Multiselect = true }) using (var d = new OpenFileDialog() { Multiselect = true })
if (d.ShowDialog() == DialogResult.OK) if (d.ShowDialog() == DialogResult.OK)
mp.Load(d.FileNames); mp.Load(d.FileNames, true, Control.ModifierKeys.HasFlag(Keys.Control));
})); }));
} }
@@ -183,9 +183,9 @@ namespace mpvnet
public static void execute_mpv_command(string[] args) public static void execute_mpv_command(string[] args)
{ {
MainForm.Instance.Invoke(new Action(() => { MainForm.Instance.Invoke(new Action(() => {
string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegistryHelp.GetString(App.RegPath, "RecentExecutedCommand")); string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegHelp.GetString(App.RegPath, "RecentExecutedCommand"));
if (string.IsNullOrEmpty(command)) return; if (string.IsNullOrEmpty(command)) return;
RegistryHelp.SetObject(App.RegPath, "RecentExecutedCommand", command); RegHelp.SetObject(App.RegPath, "RecentExecutedCommand", command);
mp.command_string(command, false); mp.command_string(command, false);
})); }));
} }
@@ -195,7 +195,7 @@ namespace mpvnet
MainForm.Instance.Invoke(new Action(() => { MainForm.Instance.Invoke(new Action(() => {
string command = VB.Interaction.InputBox("Enter URL to be opened."); string command = VB.Interaction.InputBox("Enter URL to be opened.");
if (string.IsNullOrEmpty(command)) return; if (string.IsNullOrEmpty(command)) return;
mp.Load(command); mp.Load(new [] { command }, false, Control.ModifierKeys.HasFlag(Keys.Control));
})); }));
} }

View File

@@ -13,22 +13,20 @@ using System.Runtime.Serialization;
using System.Windows.Forms; using System.Windows.Forms;
using Microsoft.Win32; using Microsoft.Win32;
using VB = Microsoft.VisualBasic;
namespace mpvnet namespace mpvnet
{ {
public class App public class App
{ {
public static string ConfFilePath { get; } = mp.ConfFolder + "\\mpvnet.conf"; public static string ConfFilePath { get; } = mp.ConfFolder + "\\mpvnet.conf";
public static string RegPath { get; } = "HKCU\\Software\\" + Application.ProductName; public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
public static string ClipboardMonitoring { get; set; } = "yes"; public static string DarkMode { get; set; } = "always";
public static string ProcessInstance { get; set; } = "single";
public static string[] VideoTypes { get; } = "mkv mp4 mpg avi mov webm vob wmv flv avs 264 h264 asf webm mpeg mpv y4m avc hevc 265 h265 m2v m2ts vpy mts m4v".Split(' '); public static string[] VideoTypes { get; } = "mkv mp4 mpg avi mov webm vob wmv flv avs 264 h264 asf webm mpeg mpv y4m avc hevc 265 h265 m2v m2ts vpy mts m4v".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[] 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; } = { "youtube", "ard", "zdf" };
public static string DarkMode { get; set; } = "always";
public static string ProcessInstance { get; set; } = "single";
public static bool DebugMode { get; set; } = false; public static bool DebugMode { get; set; } = false;
@@ -85,10 +83,12 @@ namespace mpvnet
{ {
switch (name) switch (name)
{ {
case "clipboard-monitoring": ClipboardMonitoring = value; 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;
case "url-whitelist":
UrlWhitelist = value.Split(' ', ',', ';');
break;
} }
} }
@@ -171,49 +171,49 @@ namespace mpvnet
{ {
Types = types; Types = types;
RegistryHelp.SetObject(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename, null, ExePath); RegHelp.SetObject(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename, null, ExePath);
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}", "FriendlyAppName", "mpv.net media player"); RegHelp.SetObject($"HKCR\\Applications\\{ExeFilename}", "FriendlyAppName", "mpv.net media player");
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\""); RegHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationDescription", "mpv.net media player"); RegHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationDescription", "mpv.net media player");
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationName", "mpv.net"); RegHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationName", "mpv.net");
RegistryHelp.SetObject($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}", null, ""); RegHelp.SetObject($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}", null, "");
RegistryHelp.SetObject($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}", null, ""); RegHelp.SetObject($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}", null, "");
foreach (string ext in Types) foreach (string ext in Types)
{ {
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\SupportedTypes", "." + ext, ""); RegHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\SupportedTypes", "." + ext, "");
RegistryHelp.SetObject($"HKCR\\" + "." + ext, null, ExeFilenameNoExt + "." + ext); RegHelp.SetObject($"HKCR\\" + "." + ext, null, ExeFilenameNoExt + "." + ext);
RegistryHelp.SetObject($"HKCR\\" + "." + ext + "\\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, ""); RegHelp.SetObject($"HKCR\\" + "." + ext + "\\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, "");
if (App.VideoTypes.Contains(ext)) if (App.VideoTypes.Contains(ext))
RegistryHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "video"); RegHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "video");
if (App.AudioTypes.Contains(ext)) if (App.AudioTypes.Contains(ext))
RegistryHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "audio"); RegHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "audio");
RegistryHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open", null, "Play with " + Application.ProductName); RegHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open", null, "Play with " + Application.ProductName);
RegistryHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\""); RegHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext); RegHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext);
} }
} }
public static void Unregister() public static void Unregister()
{ {
RegistryHelp.RemoveKey(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename); RegHelp.RemoveKey(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename);
RegistryHelp.RemoveKey($"HKCR\\Applications\\{ExeFilename}"); RegHelp.RemoveKey($"HKCR\\Applications\\{ExeFilename}");
RegistryHelp.RemoveKey(@"HKLM\SOFTWARE\Clients\Media\mpv.net"); RegHelp.RemoveKey(@"HKLM\SOFTWARE\Clients\Media\mpv.net");
RegistryHelp.RemoveKey($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}"); RegHelp.RemoveKey($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}");
RegistryHelp.RemoveKey($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}"); RegHelp.RemoveKey($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}");
foreach (string id in Registry.ClassesRoot.GetSubKeyNames()) foreach (string id in Registry.ClassesRoot.GetSubKeyNames())
{ {
if (id.StartsWith(ExeFilenameNoExt + ".")) if (id.StartsWith(ExeFilenameNoExt + "."))
Registry.ClassesRoot.DeleteSubKeyTree(id); Registry.ClassesRoot.DeleteSubKeyTree(id);
RegistryHelp.RemoveValue($"HKCR\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id); RegHelp.RemoveValue($"HKCR\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
RegistryHelp.RemoveValue($"HKLM\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id); RegHelp.RemoveValue($"HKLM\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
} }
} }
} }
public class RegistryHelp public class RegHelp
{ {
public static void SetObject(string path, string name, object value) public static void SetObject(string path, string name, object value)
{ {

View File

@@ -37,9 +37,9 @@ namespace mpvnet
files.Add(arg); files.Add(arg);
if (files.Count > 0) if (files.Count > 0)
RegistryHelp.SetObject(App.RegPath, "ShellFiles", files.ToArray()); RegHelp.SetObject(App.RegPath, "ShellFiles", files.ToArray());
RegistryHelp.SetObject(App.RegPath, "ProcessInstanceMode", App.ProcessInstance); RegHelp.SetObject(App.RegPath, "ProcessInstanceMode", App.ProcessInstance);
foreach(Process process in Process.GetProcessesByName("mpvnet")) foreach(Process process in Process.GetProcessesByName("mpvnet"))
{ {

View File

@@ -106,9 +106,9 @@ namespace mpvnet.Properties {
/// <summary> /// <summary>
/// Looks up a localized string similar to /// Looks up a localized string similar to
///# mpv manual: https://mpv.io/manual/master/ ///# manual: https://mpv.io/manual/master/
/// ///
///# mpv.net mpv.conf defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt ///# 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
@@ -164,12 +164,15 @@ namespace mpvnet.Properties {
/// { name = &quot;never&quot; }] /// { name = &quot;never&quot; }]
/// ///
///[[settings]] ///[[settings]]
///name = &quot;clipboard-monitoring&quot; ///name = &quot;url-whitelist&quot;
///default = &quot;yes&quot;
///filter = &quot;mpv.net&quot; ///filter = &quot;mpv.net&quot;
///help = &quot;Monitors the clipboard for URLs to play.&quot; ///help = &quot;Domain whitelist to monitor the clipboard for URLs to play.\n\nDefault: youtube ard zdf&quot;
///options = [{ name = &quot;yes&quot; }, ///
/// { name = &quot;no&quot; }]. ///[[settings]]
///name = &quot;process-instance&quot;
///default = &quot;single&quot;
///filter = &quot;mpv.net&quot;
///help = &quot;Defines if more then [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string mpvNetConfToml { internal static string mpvNetConfToml {
get { get {

View File

@@ -179,5 +179,6 @@
Wheel_Down add volume -10 Wheel_Down add volume -10
Prev playlist-prev Prev playlist-prev
Next playlist-next Next playlist-next
Ctrl+Wheel_Up no-osd seek 7
Ctrl+Wheel_Down no-osd seek -7
MBTN_LEFT_DBL cycle fullscreen MBTN_LEFT_DBL cycle fullscreen

View File

@@ -1,7 +1,7 @@
# mpv manual: https://mpv.io/manual/master/ # manual: https://mpv.io/manual/master/
# mpv.net mpv.conf defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt # 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

View File

@@ -147,8 +147,8 @@ help = "Set the startup volume. 0 means silence, 100 means no volume reduction o
[[settings]] [[settings]]
name = "alang" name = "alang"
default = ""
filter = "Audio" filter = "Audio"
type = "string"
help = "Specify a priority list of audio languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two-letter language codes, Matroska, MPEG-TS and NUT use ISO 639-2 three-letter language codes, while OGM uses a free-form identifier. See also aid.\n\nExamples\n\nmpv dvd://1 alang=hu,en chooses the Hungarian language track on a DVD and falls back on English if Hungarian is not available.\n\nmpv alang=jpn example.mkv plays a Matroska file with Japanese audio." help = "Specify a priority list of audio languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two-letter language codes, Matroska, MPEG-TS and NUT use ISO 639-2 three-letter language codes, while OGM uses a free-form identifier. See also aid.\n\nExamples\n\nmpv dvd://1 alang=hu,en chooses the Hungarian language track on a DVD and falls back on English if Hungarian is not available.\n\nmpv alang=jpn example.mkv plays a Matroska file with Japanese audio."
[[settings]] [[settings]]
@@ -163,8 +163,8 @@ options = [{ name = "no", help = "Don't automatically load external audio fil
[[settings]] [[settings]]
name = "slang" name = "slang"
default = ""
filter = "Subtitle" filter = "Subtitle"
type = "string"
help = "Specify a priority list of subtitle languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two letter language codes, Matroska uses ISO 639-2 three letter language codes while OGM uses a free-form identifier. See also sid." help = "Specify a priority list of subtitle languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two letter language codes, Matroska uses ISO 639-2 three letter language codes while OGM uses a free-form identifier. See also sid."
[[settings]] [[settings]]
@@ -179,48 +179,43 @@ options = [{ name = "no", help = "Don't automatically load external subtitle
[[settings]] [[settings]]
name = "sub-font" name = "sub-font"
default = ""
filter = "Subtitle" filter = "Subtitle"
type = "string"
help = "Specify font to use for subtitles that do not themselves specify a particular font. The default is sans-serif." help = "Specify font to use for subtitles that do not themselves specify a particular font. The default is sans-serif."
[[settings]] [[settings]]
name = "sub-font-size" name = "sub-font-size"
default = ""
filter = "Subtitle" filter = "Subtitle"
help = "Specify the sub font size. The unit is the size in scaled pixels at a window height of 720. The actual pixel size is scaled with the window height: if the window height is larger or smaller than 720, the actual size of the text increases or decreases as well. Default: 55" help = "Specify the sub font size. The unit is the size in scaled pixels at a window height of 720. The actual pixel size is scaled with the window height: if the window height is larger or smaller than 720, the actual size of the text increases or decreases as well. Default: 55"
[[settings]] [[settings]]
name = "sub-color" name = "sub-color"
default = ""
type = "color" type = "color"
filter = "Subtitle" filter = "Subtitle"
help = "Specify the color used for unstyled text subtitles.\n\nThe color is specified in the form r/g/b, where each color component is specified as number in the range 0.0 to 1.0. It's also possible to specify the transparency by using r/g/b/a, where the alpha value 0 means fully transparent, and 1.0 means opaque. If the alpha component is not given, the color is 100% opaque.\n\nPassing a single number to the option sets the sub to gray, and the form gray/a lets you specify alpha additionally.\n\nExamples\n\n1.0/0.0/0.0 set sub to opaque red\n1.0/0.0/0.0/0.75 set sub to opaque red with 75% alpha\n0.5/0.75 set sub to 50% gray with 75% alpha\n\nAlternatively, the color can be specified as a RGB hex triplet in the form #RRGGBB, where each 2-digit group expresses a color value in the range 0 (00) to 255 (FF). For example, #FF0000 is red. This is similar to web colors. Alpha is given with #AARRGGBB.\n\nExamples\n\n#FF0000 set sub to opaque red\n#C0808080 set sub to 50% gray with 75% alpha" help = "Specify the color used for unstyled text subtitles.\n\nThe color is specified in the form r/g/b, where each color component is specified as number in the range 0.0 to 1.0. It's also possible to specify the transparency by using r/g/b/a, where the alpha value 0 means fully transparent, and 1.0 means opaque. If the alpha component is not given, the color is 100% opaque.\n\nPassing a single number to the option sets the sub to gray, and the form gray/a lets you specify alpha additionally.\n\nExamples\n\n1.0/0.0/0.0 set sub to opaque red\n1.0/0.0/0.0/0.75 set sub to opaque red with 75% alpha\n0.5/0.75 set sub to 50% gray with 75% alpha\n\nAlternatively, the color can be specified as a RGB hex triplet in the form #RRGGBB, where each 2-digit group expresses a color value in the range 0 (00) to 255 (FF). For example, #FF0000 is red. This is similar to web colors. Alpha is given with #AARRGGBB.\n\nExamples\n\n#FF0000 set sub to opaque red\n#C0808080 set sub to 50% gray with 75% alpha"
[[settings]] [[settings]]
name = "sub-border-color" name = "sub-border-color"
default = ""
type = "color" type = "color"
filter = "Subtitle" filter = "Subtitle"
help = "See sub-color. Color used for the sub font border. Ignored when sub-back-color is specified (or more exactly: when that option is not set to completely transparent)." help = "See sub-color. Color used for the sub font border. Ignored when sub-back-color is specified (or more exactly: when that option is not set to completely transparent)."
[[settings]] [[settings]]
name = "sub-back-color" name = "sub-back-color"
default = ""
type = "color" type = "color"
filter = "Subtitle" filter = "Subtitle"
help = "See sub-color. Color used for sub text background. You can use sub-shadow-offset to change its size relative to the text." help = "See sub-color. Color used for sub text background. You can use sub-shadow-offset to change its size relative to the text."
[[settings]] [[settings]]
name = "screen" name = "screen"
default = ""
filter = "Screen" filter = "Screen"
help = "<0-32> In multi-monitor configurations (i.e. a single desktop that spans across multiple displays), this option tells mpv which screen to display the video on." help = "<0-32> In multi-monitor configurations (i.e. a single desktop that spans across multiple displays), this option tells mpv which screen to display the video on."
[[settings]] [[settings]]
name = "osd-playing-msg" name = "osd-playing-msg"
default = ""
width = 300 width = 300
filter = "Screen" filter = "Screen"
type = "string"
help = "Show a message on OSD when playback starts. The string is expanded for properties, e.g. osd-playing-msg='file: ${filename}' will show the message file: followed by a space and the currently played filename. For more information visit:" help = "Show a message on OSD when playback starts. The string is expanded for properties, e.g. osd-playing-msg='file: ${filename}' will show the message file: followed by a space and the currently played filename. For more information visit:"
helpurl = "https://mpv.io/manual/master/#property-expansion" helpurl = "https://mpv.io/manual/master/#property-expansion"
@@ -240,7 +235,6 @@ options = [{ name = "yes" },
[[settings]] [[settings]]
name = "screenshot-directory" name = "screenshot-directory"
default = ""
width = 500 width = 500
type = "folder" type = "folder"
filter = "Screen" filter = "Screen"
@@ -271,7 +265,6 @@ options = [{ name = "yes", help = "Don't terminate if the current file is the
[[settings]] [[settings]]
name = "loop-file" name = "loop-file"
default = ""
filter = "Playback" filter = "Playback"
help = "Loop a single file N times. inf means forever, no means normal playback.\n\nThe difference to loop-playlist is that this doesn't loop the playlist, just the file itself. If the playlist contains only a single file, the difference between the two option is that this option performs a seek on loop, instead of reloading the file. loop is an alias for this option." help = "Loop a single file N times. inf means forever, no means normal playback.\n\nThe difference to loop-playlist is that this doesn't loop the playlist, just the file itself. If the playlist contains only a single file, the difference between the two option is that this option performs a seek on loop, instead of reloading the file. loop is an alias for this option."
@@ -285,13 +278,11 @@ options = [{ name = "yes" },
[[settings]] [[settings]]
name = "input-ar-delay" name = "input-ar-delay"
default = ""
filter = "Input" filter = "Input"
help = "Delay in milliseconds before we start to autorepeat a key (0 to disable)." help = "Delay in milliseconds before we start to autorepeat a key (0 to disable)."
[[settings]] [[settings]]
name = "input-ar-rate" name = "input-ar-rate"
default = ""
filter = "Input" filter = "Input"
help = "Number of key presses to generate per second on autorepeat." help = "Number of key presses to generate per second on autorepeat."
@@ -315,6 +306,5 @@ options = [{ name = "yes" },
[[settings]] [[settings]]
name = "loop-playlist" name = "loop-playlist"
default = ""
filter = "Playback" filter = "Playback"
help = "<N|inf|force|no> Loops playback N times. A value of 1 plays it one time (default), 2 two times, etc. inf means forever. no is the same as 1 and disables looping. If several files are specified on command line, the entire playlist is looped. The force mode is like inf, but does not skip playlist entries which have been marked as failing. This means the player might waste CPU time trying to loop a file that doesn't exist. But it might be useful for playing webradios under very bad network conditions." help = "<N|inf|force|no> Loops playback N times. A value of 1 plays it one time (default), 2 two times, etc. inf means forever. no is the same as 1 and disables looping. If several files are specified on command line, the entire playlist is looped. The force mode is like inf, but does not skip playlist entries which have been marked as failing. This means the player might waste CPU time trying to loop a file that doesn't exist. But it might be useful for playing webradios under very bad network conditions."

View File

@@ -8,12 +8,10 @@ options = [{ name = "always" },
{ name = "never" }] { name = "never" }]
[[settings]] [[settings]]
name = "clipboard-monitoring" name = "url-whitelist"
default = "yes"
filter = "mpv.net" filter = "mpv.net"
help = "Monitors the clipboard for URLs to play." type = "string"
options = [{ name = "yes" }, help = "Domain whitelist to monitor the clipboard for URLs to play.\n\nDefault: youtube ard zdf"
{ name = "no" }]
[[settings]] [[settings]]
name = "process-instance" name = "process-instance"

View File

@@ -28,7 +28,7 @@ namespace mpvnet
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged; SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
LoadSettings(SettingsDefinitions, Conf); LoadSettings(SettingsDefinitions, Conf);
LoadSettings(NetSettingsDefinitions, NetConf); LoadSettings(NetSettingsDefinitions, NetConf);
SearchControl.Text = RegistryHelp.GetString(@"HKCU\Software\mpv.net", "config editor search"); SearchControl.Text = RegHelp.GetString(App.RegPath, "config editor search");
if (App.IsDarkMode) if (App.IsDarkMode)
{ {
@@ -49,7 +49,7 @@ namespace mpvnet
private void LoadSettings(List<SettingBase> settingsDefinitions, private void LoadSettings(List<SettingBase> settingsDefinitions,
Dictionary<string, string> confSettings) Dictionary<string, string> confSettings)
{ {
foreach (var setting in settingsDefinitions) foreach (SettingBase setting in settingsDefinitions)
{ {
if (!FilterStrings.Contains(setting.Filter)) if (!FilterStrings.Contains(setting.Filter))
FilterStrings.Add(setting.Filter); FilterStrings.Add(setting.Filter);
@@ -58,7 +58,7 @@ namespace mpvnet
{ {
if (setting.Name == pair.Key) if (setting.Name == pair.Key)
{ {
setting.Value = pair.Value; setting.Value = pair.Value.Trim('\'', '"');
setting.StartValue = pair.Value; setting.StartValue = pair.Value;
continue; continue;
} }
@@ -132,7 +132,7 @@ namespace mpvnet
{ {
base.OnClosed(e); base.OnClosed(e);
WriteToDisk(); WriteToDisk();
RegistryHelp.SetObject(@"HKCU\Software\mpv.net", "config editor search", SearchControl.Text); RegHelp.SetObject(App.RegPath, "config editor search", SearchControl.Text);
} }
void WriteToDisk() void WriteToDisk()
@@ -165,17 +165,22 @@ namespace mpvnet
foreach (var i in Comments[filePath]) foreach (var i in Comments[filePath])
content += $"#{i.Key} = {i.Value}\r\n"; content += $"#{i.Key} = {i.Value}\r\n";
foreach (var setting in settings) foreach (SettingBase setting in settings)
{ {
if ((setting.Value ?? "") != setting.Default) if ((setting.Value ?? "") != setting.Default)
confSettings[setting.Name] = setting.Value; if (setting.Type == "string" ||
setting.Type == "folder" ||
setting.Type == "color")
confSettings[setting.Name] = "'" + setting.Value + "'";
else
confSettings[setting.Name] = setting.Value;
if (confSettings.ContainsKey(setting.Name) && if (confSettings.ContainsKey(setting.Name) &&
(setting.Value ?? "") == setting.Default || (setting.Value ?? "") == setting.Default ||
(setting.Value ?? "") == "") (setting.Value ?? "") == "")
{
confSettings.Remove(setting.Name); confSettings.Remove(setting.Name);
}
} }
foreach (var i in confSettings) foreach (var i in confSettings)

View File

@@ -95,12 +95,8 @@ namespace mpvnet
ListView.ScrollIntoView(ListView.SelectedItem); ListView.ScrollIntoView(ListView.SelectedItem);
} }
break; break;
case Key.Escape: case Key.Escape: Close(); break;
Close(); case Key.Enter: Execute(); break;
break;
case Key.Enter:
Execute();
break;
} }
} }
@@ -113,14 +109,11 @@ namespace mpvnet
void Execute() void Execute()
{ {
if (ListView.SelectedItem != null) if (ListView.SelectedItem != null)
mp.Load(ListView.SelectedItem as string); mp.Load(new[] { ListView.SelectedItem as string }, true, Keyboard.Modifiers == ModifierKeys.Control);
Keyboard.Focus(FilterTextBox); Keyboard.Focus(FilterTextBox);
} }
private void ListView_MouseUp(object sender, MouseButtonEventArgs e) private void ListView_MouseUp(object sender, MouseButtonEventArgs e) => Execute();
{
Execute();
}
private void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e) private void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e)
{ {

View File

@@ -40,7 +40,7 @@ namespace mpvnet
MinimumSize = new Size(FontHeight * 16, FontHeight * 9); MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
Text += " " + Application.ProductVersion; Text += " " + Application.ProductVersion;
object recent = RegistryHelp.GetObject(App.RegPath, "Recent"); object recent = RegHelp.GetObject(App.RegPath, "Recent");
if (recent is string[] r) if (recent is string[] r)
RecentFiles = new List<string>(r); RecentFiles = new List<string>(r);
@@ -150,7 +150,7 @@ namespace mpvnet
recent.DropDownItems.Clear(); recent.DropDownItems.Clear();
foreach (string path in RecentFiles) foreach (string path in RecentFiles)
MenuItem.Add(recent.DropDownItems, path, () => mp.Load(path)); 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");
@@ -377,14 +377,14 @@ namespace mpvnet
if (m.Msg == SingleProcess.Message) if (m.Msg == SingleProcess.Message)
{ {
object filesObject = RegistryHelp.GetObject(App.RegPath, "ShellFiles"); object filesObject = RegHelp.GetObject(App.RegPath, "ShellFiles");
if (filesObject is string[] files) if (filesObject is string[] files)
{ {
switch (RegistryHelp.GetString(App.RegPath, "ProcessInstanceMode")) switch (RegHelp.GetString(App.RegPath, "ProcessInstanceMode"))
{ {
case "single": case "single":
mp.Load(files); mp.Load(files, true, Control.ModifierKeys.HasFlag(Keys.Control));
break; break;
case "queue": case "queue":
foreach (string file in files) foreach (string file in files)
@@ -393,7 +393,7 @@ namespace mpvnet
} }
} }
RegistryHelp.RemoveValue(App.RegPath, "ShellFiles"); RegHelp.RemoveValue(App.RegPath, "ShellFiles");
Activate(); Activate();
return; return;
} }
@@ -412,9 +412,9 @@ namespace mpvnet
{ {
base.OnDragDrop(e); base.OnDragDrop(e);
if (e.Data.GetDataPresent(DataFormats.FileDrop)) if (e.Data.GetDataPresent(DataFormats.FileDrop))
mp.Load(e.Data.GetData(DataFormats.FileDrop) as String[]); mp.Load(e.Data.GetData(DataFormats.FileDrop) as String[], true, Control.ModifierKeys.HasFlag(Keys.Control));
if (e.Data.GetDataPresent(DataFormats.Text)) if (e.Data.GetDataPresent(DataFormats.Text))
mp.Load(e.Data.GetData(DataFormats.Text).ToString()); mp.Load(new[] { e.Data.GetData(DataFormats.Text).ToString() }, true, Control.ModifierKeys.HasFlag(Keys.Control));
} }
protected override void OnMouseDown(MouseEventArgs e) protected override void OnMouseDown(MouseEventArgs e)
@@ -487,7 +487,7 @@ namespace mpvnet
BuildMenu(); BuildMenu();
ContextMenuStrip = ContextMenu; ContextMenuStrip = ContextMenu;
IgnoreDpiChanged = false; IgnoreDpiChanged = false;
CheckURLinClipboard(); CheckUrlInClipboard();
} }
protected override void OnResize(EventArgs e) protected override void OnResize(EventArgs e)
@@ -499,7 +499,7 @@ namespace mpvnet
protected override void OnFormClosed(FormClosedEventArgs e) protected override void OnFormClosed(FormClosedEventArgs e)
{ {
base.OnFormClosed(e); base.OnFormClosed(e);
RegistryHelp.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.AutoResetEvent.WaitOne(3000);
@@ -514,20 +514,24 @@ namespace mpvnet
protected override void OnActivated(EventArgs e) protected override void OnActivated(EventArgs e)
{ {
base.OnActivated(e); base.OnActivated(e);
CheckURLinClipboard(); CheckUrlInClipboard();
} }
void CheckURLinClipboard() void CheckUrlInClipboard()
{ {
if (App.ClipboardMonitoring != "yes") return;
string clipboard = Clipboard.GetText(); string clipboard = Clipboard.GetText();
if (clipboard.StartsWith("http") && RegistryHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible) foreach (string url in App.UrlWhitelist)
{ {
RegistryHelp.SetObject(App.RegPath, "LastURL", clipboard); if (clipboard.Contains("://") && !clipboard.Contains("\n") &&
clipboard.Contains(url.ToLower()) &&
RegHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible)
{
RegHelp.SetObject(App.RegPath, "LastURL", clipboard);
if (Msg.ShowQuestion("Play URL?", clipboard) == MsgResult.OK) if (Msg.ShowQuestion("Play URL?", clipboard) == MsgResult.OK)
mp.Load(clipboard); mp.Load(new[] { clipboard }, true, Control.ModifierKeys.HasFlag(Keys.Control));
}
} }
} }
} }

View File

@@ -538,11 +538,11 @@ namespace mpvnet
{ {
files.Add(i); files.Add(i);
if (i.StartsWith("http")) if (i.StartsWith("http"))
RegistryHelp.SetObject(App.RegPath, "LastURL", i); RegHelp.SetObject(App.RegPath, "LastURL", i);
} }
} }
mp.Load(files.ToArray()); mp.Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
foreach (string i in args) foreach (string i in args)
{ {
@@ -560,7 +560,7 @@ namespace mpvnet
} }
} }
public static void Load(params string[] files) public static void Load(string[] files, bool loadFolder, bool append)
{ {
if (files is null || files.Length == 0) return; if (files is null || files.Length == 0) return;
HideLogo(); HideLogo();
@@ -569,12 +569,12 @@ namespace mpvnet
if (App.SubtitleTypes.Contains(Path.GetExtension(files[i]).TrimStart('.').ToLower())) if (App.SubtitleTypes.Contains(Path.GetExtension(files[i]).TrimStart('.').ToLower()))
mp.commandv("sub-add", files[i]); mp.commandv("sub-add", files[i]);
else else
if (i == 0) if (i == 0 && !append)
mp.commandv("loadfile", files[i]); mp.commandv("loadfile", files[i]);
else else
mp.commandv("loadfile", files[i], "append"); mp.commandv("loadfile", files[i], "append");
Task.Run(() => LoadFolder()); // user reported race condition if (loadFolder && !append) Task.Run(() => LoadFolder()); // user reported race condition
} }
static void LoadFolder() static void LoadFolder()