File associations and auto-load-folder can be customized
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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}");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -570,6 +570,27 @@ file = "mpvnet"
|
||||
filter = "General"
|
||||
help = "<int> 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"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBox Name="FilterTextBox"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -11,6 +10,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
using DynamicGUI;
|
||||
|
||||
using static mpvnet.Core;
|
||||
|
||||
namespace mpvnet
|
||||
@@ -56,12 +56,10 @@ namespace mpvnet
|
||||
switch (setting)
|
||||
{
|
||||
case StringSetting s:
|
||||
var sc = new StringSettingControl(s);
|
||||
MainStackPanel.Children.Add(sc);
|
||||
MainStackPanel.Children.Add(new StringSettingControl(s));
|
||||
break;
|
||||
case OptionSetting s:
|
||||
var oc = new OptionSettingControl(s);
|
||||
MainStackPanel.Children.Add(oc);
|
||||
MainStackPanel.Children.Add(new OptionSettingControl(s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,9 +142,7 @@ namespace mpvnet
|
||||
Everything_GetResultFullPathName(i, sb, (uint)sb.Capacity);
|
||||
string ext = sb.ToString().Ext();
|
||||
|
||||
if (App.AudioTypes.Contains(ext) || App.VideoTypes.Contains(ext)
|
||||
|| App.ImageTypes.Contains(ext))
|
||||
|
||||
if (App.AudioTypes.Contains(ext) || App.VideoTypes.Contains(ext) || App.ImageTypes.Contains(ext))
|
||||
items.Add(sb.ToString());
|
||||
|
||||
if (items.Count > 100)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
Reference in New Issue
Block a user