diff --git a/Changelog.md b/Changelog.md index 7a2fa57..958620d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,12 +1,14 @@ -5.4.8.7 Beta (202?-??-??) +5.4.8.7 Beta (2021-03-??) ========================= - History feature can be configured to ingore defined strings: script-opt = history-discard=value1;value2 - Web stream audio and subtitle track selection. -- On Windows 10 1903 and later the default code page was changed to UTF8. +- On Windows 10 1903 and later the default code page was changed to UTF-8. - Support of --version command. +- File associations and auto-load-folder can be customized with + video-file-extensions, audio-file-extensions and image-file-extensions 5.4.8.6 Beta (2020-12-24) diff --git a/mpv.net/Misc/App.cs b/mpv.net/Misc/App.cs index 69f9992..965f741 100644 --- a/mpv.net/Misc/App.cs +++ b/mpv.net/Misc/App.cs @@ -12,9 +12,9 @@ namespace mpvnet { public static class App { - public static string[] VideoTypes { get; } = "264 265 asf avc avi avs dav flv h264 h265 hevc m2t m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm wmv y4m".Split(' '); - public static string[] AudioTypes { get; } = "mp3 mp2 ac3 ogg opus flac wav w64 m4a dts dtsma dtshr dtshd eac3 thd thd+ac3 mka aac mpa".Split(' '); - public static string[] ImageTypes { get; } = { "jpg", "bmp", "gif", "png" }; + public static string[] VideoTypes { get; set; } = "264 265 asf avc avi avs dav flv h264 h265 hevc m2t m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm wmv y4m".Split(' '); + public static string[] AudioTypes { get; set; } = "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; set; } = { "jpg", "bmp", "gif", "png" }; public static string[] SubtitleTypes { get; } = { "srt", "ass", "idx", "sup", "ttxt", "ssa", "smi" }; public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName; @@ -190,6 +190,9 @@ namespace mpvnet case "minimum-aspect-ratio": MinimumAspectRatio = value.ToFloat(); return true; case "dark-theme": DarkTheme = value.Trim('\'', '"'); return true; case "light-theme": LightTheme = value.Trim('\'', '"'); return true; + case "video-file-extensions": VideoTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true; + case "audio-file-extensions": AudioTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true; + case "image-file-extensions": ImageTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true; default: if (writeError) ConsoleHelp.WriteError($"unknown mpvnet.conf property: {name}"); diff --git a/mpv.net/Misc/Program.cs b/mpv.net/Misc/Program.cs index e7ac2fc..4cf87d2 100644 --- a/mpv.net/Misc/Program.cs +++ b/mpv.net/Misc/Program.cs @@ -28,11 +28,17 @@ namespace mpvnet string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray(); - if (args.Length == 2 && args[0] == "--reg-file-assoc") + if (args.Length >= 2 && args[0] == "--reg-file-assoc") { - if (args[1] == "audio") FileAssociation.Register(App.AudioTypes); - if (args[1] == "video") FileAssociation.Register(App.VideoTypes); - if (args[1] == "image") FileAssociation.Register(App.ImageTypes); + if (args[1] == "audio") + FileAssociation.Register(App.AudioTypes); + else if (args[1] == "video") + FileAssociation.Register(App.VideoTypes); + else if (args[1] == "image") + FileAssociation.Register(App.ImageTypes); + else + FileAssociation.Register(args.Skip(1).ToArray()); + return; } diff --git a/mpv.net/Resources/editor.toml.txt b/mpv.net/Resources/editor.toml.txt index dd6985d..49e2230 100644 --- a/mpv.net/Resources/editor.toml.txt +++ b/mpv.net/Resources/editor.toml.txt @@ -570,6 +570,27 @@ file = "mpvnet" filter = "General" help = " Amount of recent files to be remembered. Default: 15 (mpv.net specific setting)" +[[settings]] +name = "video-file-extensions" +file = "mpvnet" +filter = "General" +width = 500 +help = "Video file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific setting)" + +[[settings]] +name = "audio-file-extensions" +file = "mpvnet" +filter = "General" +width = 500 +help = "Audio file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific setting)" + +[[settings]] +name = "image-file-extensions" +file = "mpvnet" +filter = "General" +width = 500 +help = "Image file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific setting)" + [[settings]] name = "debug-mode" file = "mpvnet" diff --git a/mpv.net/WPF/CommandPaletteWindow.xaml b/mpv.net/WPF/CommandPaletteWindow.xaml index 4f3b5c2..0fa48c8 100644 --- a/mpv.net/WPF/CommandPaletteWindow.xaml +++ b/mpv.net/WPF/CommandPaletteWindow.xaml @@ -17,7 +17,7 @@ - + 100) diff --git a/mpv.net/WPF/SetupWindow.xaml.cs b/mpv.net/WPF/SetupWindow.xaml.cs index ffb0d88..45f483a 100644 --- a/mpv.net/WPF/SetupWindow.xaml.cs +++ b/mpv.net/WPF/SetupWindow.xaml.cs @@ -1,7 +1,6 @@  using System; using System.Diagnostics; -using System.IO; using System.Windows.Interop; using System.Windows.Media.Imaging; using System.Windows; @@ -31,27 +30,29 @@ namespace mpvnet } } - void RegisterFileAssociations(string value) + void RegFileAssoc(string[] extensions) { try { using (Process proc = new Process()) { proc.StartInfo.FileName = WinForms.Application.ExecutablePath; - proc.StartInfo.Arguments = "--reg-file-assoc " + value; + proc.StartInfo.Arguments = "--reg-file-assoc " + String.Join(" ", extensions); proc.StartInfo.Verb = "runas"; proc.StartInfo.UseShellExecute = true; proc.Start(); + proc.WaitForExit(); + + if (proc.ExitCode == 0) + Msg.Show("File associations successfully created."); } - Msg.Show(value[0].ToString().ToUpper() + value.Substring(1) + - " file associations successfully created."); } catch {} } - void AddVideo_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("video"); - void AddAudio_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("audio"); - void AddImage_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("image"); + void AddVideo_Click(object sender, RoutedEventArgs e) => RegFileAssoc(App.VideoTypes); + void AddAudio_Click(object sender, RoutedEventArgs e) => RegFileAssoc(App.AudioTypes); + void AddImage_Click(object sender, RoutedEventArgs e) => RegFileAssoc(App.ImageTypes); void RemoveFileAssociations_Click(object sender, RoutedEventArgs e) { @@ -60,7 +61,7 @@ namespace mpvnet using (Process proc = new Process()) { proc.StartInfo.FileName = "powershell.exe"; - proc.StartInfo.Arguments = "-NoLogo -NoExit -ExecutionPolicy Bypass -File \"" + + proc.StartInfo.Arguments = "-NoLogo -NoExit -NoProfile -ExecutionPolicy Bypass -File \"" + Folder.Startup + "Setup\\remove file associations.ps1\""; proc.StartInfo.Verb = "runas"; proc.StartInfo.UseShellExecute = true; @@ -96,7 +97,8 @@ namespace mpvnet void ExecutePowerShellScript(string file) { - ProcessHelp.Execute("powershell.exe", "-NoLogo -NoExit -ExecutionPolicy Bypass -File \"" + file + "\""); + ProcessHelp.Execute("powershell.exe", + "-NoLogo -NoExit -NoProfile -ExecutionPolicy Bypass -File \"" + file + "\""); } void EditDefaultApp_Click(object sender, RoutedEventArgs e) diff --git a/mpv.net/WinForms/Menu.cs b/mpv.net/WinForms/Menu.cs index 9c703cd..ca5aac0 100644 --- a/mpv.net/WinForms/Menu.cs +++ b/mpv.net/WinForms/Menu.cs @@ -1,4 +1,5 @@ -using System; + +using System; using System.Linq; using System.ComponentModel; using System.Drawing.Drawing2D;