feat: dotnet 9, CPM, etc

This commit is contained in:
Benjamin Nomine
2025-01-11 14:05:54 -05:00
parent ace7566c2a
commit 01477d8b25
22 changed files with 213 additions and 128 deletions

View File

@@ -5,3 +5,6 @@ csharp_style_implicit_object_creation_when_type_is_apparent = true
# IDE0090: Use 'new(...)'
dotnet_diagnostic.IDE0090.severity = silent
# WFO1000: A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method
dotnet_diagnostic.WFO1000.severity = silent

View File

@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<Product>mpv.net</Product>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageVersion Include="NGettext" Version="0.6.7" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" />
</ItemGroup>
</Project>

View File

@@ -101,8 +101,8 @@ public class ConfParser
}
else if (line.Contains('='))
{
string name = line[..line.IndexOf("=")].Trim();
string value = line[(line.IndexOf("=") + 1)..].Trim();
string name = line[..line.IndexOf('=')].Trim();
string value = line[(line.IndexOf('=') + 1)..].Trim();
currentGroup?.Items.Add(new StringPair(name, value));
}

View File

@@ -13,7 +13,7 @@ public static class FileAssociation
string exeFilename = Path.GetFileName(exePath);
string exeFilenameNoExt = Path.GetFileNameWithoutExtension(exePath);
string[] protocols = { "ytdl", "rtsp", "srt", "srtp" };
string[] protocols = ["ytdl", "rtsp", "srt", "srtp"];
if (perceivedType != "unreg")
{

View File

@@ -198,11 +198,13 @@ public class GuiCommand
else
{
string clipboard = System.Windows.Forms.Clipboard.GetText();
List<string> files = new List<string>();
List<string> files = [];
foreach (string i in clipboard.Split(BR.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
{
if (i.Contains("://") || File.Exists(i))
files.Add(i);
}
if (files.Count == 0)
{
@@ -227,9 +229,13 @@ public class GuiCommand
dialog.Multiselect = true;
if (dialog.ShowDialog() == DialogResult.OK)
foreach (string i in dialog.FileNames)
Player.CommandV("audio-add", i);
if (dialog.ShowDialog() != DialogResult.OK)
return;
foreach (string i in dialog.FileNames)
{
Player.CommandV("audio-add", i);
}
}
void RegisterFileAssociations(IList<string> args)
@@ -313,9 +319,11 @@ public class GuiCommand
var items = new List<Item>();
foreach (string file in App.Settings.RecentFiles)
{
items.Add(new Item() { title = Path.GetFileName(file),
value = new string []{ "loadfile", file },
hint = file});
value = ["loadfile", file],
hint = file});
}
o.items = items.ToArray();
string json = JsonSerializer.Serialize(o);
@@ -326,12 +334,12 @@ public class GuiCommand
{
public string title { get; set; } = "";
public int selected_index { get; set; } = 0;
public Item[] items { get; set; } = Array.Empty<Item>();
public Item[] items { get; set; } = [];
}
class Item
{
public string[] value { get; set; } = Array.Empty<string>();
public string[] value { get; set; } = [];
public string title { get; set; } = "";
public string hint { get; set; } = "";
}
@@ -393,15 +401,21 @@ public class GuiCommand
}
if (App.MediaInfo && !osd && File.Exists(path) && !path.Contains(@"\\.\pipe\"))
using (MediaInfo mediaInfo = new MediaInfo(path))
text = Regex.Replace(mediaInfo.GetSummary(full, raw), "Unique ID.+", "");
{
using MediaInfo mediaInfo = new MediaInfo(path);
text = Regex.Replace(mediaInfo.GetSummary(full, raw), "Unique ID.+", "");
}
else
{
Player.UpdateExternalTracks();
text = "N: " + Player.GetPropertyString("filename") + BR;
lock (Player.MediaTracksLock)
{
foreach (MediaTrack track in Player.MediaTracks)
{
text += track.Text + BR;
}
}
}
text = text.TrimEx();
@@ -426,7 +440,7 @@ public class GuiCommand
{
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!;
if (path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower()))
if (path.Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar), StringComparison.CurrentCultureIgnoreCase))
{
Msg.ShowWarning(_("mpv.net is already in the Path environment variable."));
return;

View File

@@ -1,49 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<RootNamespace>MpvNet.Windows</RootNamespace>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows</TargetFramework>
<RootNamespace>MpvNet.Windows</RootNamespace>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PublishSingleFile>true</PublishSingleFile>
<AssemblyName>mpvnet</AssemblyName>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>mpv-icon.ico</ApplicationIcon>
<Product>mpv.net</Product>
<FileVersion>7.1.1.3</FileVersion>
<AssemblyVersion>7.1.1.3</AssemblyVersion>
<AssemblyName>mpvnet</AssemblyName>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>mpv-icon.ico</ApplicationIcon>
<FileVersion>7.1.1.3</FileVersion>
<AssemblyVersion>7.1.1.3</AssemblyVersion>
<InformationalVersion>7.1.1.3</InformationalVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Misc\**" />
<EmbeddedResource Remove="Misc\**" />
<None Remove="Misc\**" />
<Page Remove="Misc\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Misc\**" />
<EmbeddedResource Remove="Misc\**" />
<None Remove="Misc\**" />
<Page Remove="Misc\**" />
</ItemGroup>
<ItemGroup>
<Content Include="mpv-icon.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="mpv-icon.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MpvNet\MpvNet.csproj" />
<ProjectReference Include="..\NGettext.Wpf\NGettext.Wpf.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MpvNet\MpvNet.csproj" />
<ProjectReference Include="..\NGettext.Wpf\NGettext.Wpf.csproj" />
</ItemGroup>
<ItemGroup>
<Page Update="WPF\Views\AboutWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="WPF\Views\AboutWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" />
</ItemGroup>
</Project>

View File

@@ -13,6 +13,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2F97C77E-32E3-46FA-8D7C-3940FD9AA384}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NGettext.Wpf", "NGettext.Wpf\NGettext.Wpf.csproj", "{0B7958FD-2138-482A-A21B-481AE7A0F851}"

View File

@@ -19,7 +19,7 @@ public class Chapter
_timeDisplay = TimeSpan.FromSeconds(Time).ToString();
if (_timeDisplay.ContainsEx("."))
_timeDisplay = _timeDisplay[.._timeDisplay.LastIndexOf(".")];
_timeDisplay = _timeDisplay[.._timeDisplay.LastIndexOf('.')];
}
return _timeDisplay;

View File

@@ -42,7 +42,7 @@ public class Command
{
if (i.Contains("://") || File.Exists(i))
{
Player.LoadFiles(new[] { i }, true, false);
Player.LoadFiles([i], true, false);
break;
}
}

View File

@@ -17,7 +17,7 @@ public class CommandLine
if (_arguments != null)
return _arguments;
_arguments = new();
_arguments = [];
foreach (string i in Environment.GetCommandLineArgs().Skip(1))
{
@@ -37,7 +37,7 @@ public class CommandLine
arg += "=yes";
}
string left = arg[2..arg.IndexOf("=")];
string left = arg[2..arg.IndexOf('=')];
string right = arg[(left.Length + 3)..];
if (string.IsNullOrEmpty(left))
@@ -113,16 +113,19 @@ public class CommandLine
public static void ProcessCommandLineFiles()
{
List<string> files = new List<string>();
List<string> files = [];
foreach (string arg in Environment.GetCommandLineArgs().Skip(1))
{
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") ||
arg.Contains(":\\") || arg.StartsWith("\\\\") || arg.StartsWith(".") ||
arg.Contains(":\\") || arg.StartsWith("\\\\") || arg.StartsWith('.') ||
File.Exists(arg)))
{
files.Add(arg);
}
}
Player.LoadFiles(files.ToArray(), !App.Queue, App.Queue);
Player.LoadFiles([.. files], !App.Queue, App.Queue);
if (App.CommandLine.Contains("--shuffle"))
{
@@ -134,8 +137,10 @@ public class CommandLine
public static bool Contains(string name)
{
foreach (StringPair pair in Arguments)
{
if (pair.Name == name)
return true;
}
return false;
}
@@ -143,8 +148,10 @@ public class CommandLine
public static string GetValue(string name)
{
foreach (StringPair pair in Arguments)
{
if (pair.Name == name)
return pair.Value;
}
return "";
}

View File

@@ -9,7 +9,7 @@ public class ExtensionLoader
{
public event Action<Exception>? UnhandledException;
readonly List<object?> _refs = new();
readonly List<object?> _refs = [];
void LoadDll(string path)
{
@@ -31,8 +31,12 @@ public class ExtensionLoader
public void LoadFolder(string path)
{
if (Directory.Exists(path))
{
foreach (string dir in Directory.GetDirectories(path))
{
LoadDll(dir.AddSep() + Path.GetFileName(dir) + ".dll");
}
}
}
}

View File

@@ -32,12 +32,12 @@ public static class PathStringExtension
int index = instance.LastIndexOf('\\');
if (index > -1)
return instance.Substring(index + 1);
return instance[(index + 1)..];
index = instance.LastIndexOf('/');
if (index > -1)
return instance.Substring(index + 1);
return instance[(index + 1)..];
return instance;
}

View File

@@ -5,7 +5,7 @@ namespace MpvNet;
public static class FileTypes
{
public static string[] Subtitle { get; } = { "srt", "ass", "idx", "sub", "sup", "ttxt", "txt", "ssa", "smi", "mks" };
public static string[] Subtitle { get; } = ["srt", "ass", "idx", "sub", "sup", "ttxt", "txt", "ssa", "smi", "mks"];
public static bool IsVideo(string[] exts, string ext) => exts?.Contains(ext) ?? false;
public static bool IsAudio(string[] exts, string ext) => exts?.Contains(ext) ?? false;
@@ -20,7 +20,7 @@ public static class FileTypes
string exts = Player.GetPropertyString("video-exts");
if (string.IsNullOrEmpty(exts))
return "mkv mp4 avi mov flv mpg webm wmv ts vob 264 265 asf avc avs dav h264 h265 hevc m2t m2ts m2v m4v mpeg mpv mts vpy y4m".Split(' ');
return ["mkv", "mp4", "avi", "mov", "flv", "mpg", "webm", "wmv", "ts", "vob", "264", "265", "asf", "avc", "avs", "dav", "h264", "h265", "hevc", "m2t", "m2ts", "m2v", "m4v", "mpeg", "mpv", "mts", "vpy", "y4m"];
return exts.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
}
@@ -30,7 +30,7 @@ public static class FileTypes
string exts = Player.GetPropertyString("audio-exts");
if (string.IsNullOrEmpty(exts))
return "mp3 flac m4a mka mp2 ogg opus aac ac3 dts dtshd dtshr dtsma eac3 mpa mpc thd w64 wav".Split(' ');
return ["mp3", "flac", "m4a", "mka", "mp2", "ogg", "opus", "aac", "ac3", "dts", "dtshd", "dtshr", "dtsma", "eac3", "mpa", "mpc", "thd", "w64", "wav"];
return exts.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
}
@@ -40,7 +40,7 @@ public static class FileTypes
string exts = Player.GetPropertyString("image-exts");
if (string.IsNullOrEmpty(exts))
return new string[]{ "jpg", "bmp", "png", "gif", "webp" };
return ["jpg", "bmp", "png", "gif", "webp"];
return exts.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
}

View File

@@ -8,9 +8,7 @@ public static class StringHelp
{
public static string GetMD5Hash(string txt)
{
using MD5 md5 = MD5.Create();
byte[] inputBuffer = Encoding.UTF8.GetBytes(txt);
byte[] hashBuffer = md5.ComputeHash(inputBuffer);
return BitConverter.ToString(md5.ComputeHash(inputBuffer)).Replace("-", "");
return Convert.ToHexString(MD5.HashData(inputBuffer));
}
}

View File

@@ -34,17 +34,25 @@ public class InputConf
var defaultBindings = InputHelp.GetDefaults();
foreach (Binding defaultBinding in defaultBindings)
{
foreach (Binding confBinding in confbindings)
{
if (defaultBinding.Input == confBinding.Input &&
defaultBinding.Command != confBinding.Command)
{
defaultBinding.Input = "";
}
}
}
foreach (Binding defaultBinding in defaultBindings)
{
foreach (Binding confBinding in confbindings)
{
if (defaultBinding.Command == confBinding.Command)
defaultBinding.Input = confBinding.Input;
}
}
return (defaultBindings, confbindings);
}
@@ -82,16 +90,22 @@ public class InputConf
var conf = InputHelp.Parse(Content);
foreach (Binding defaultBinding in defaults)
{
foreach (Binding confBinding in conf)
{
if (defaultBinding.Command == confBinding.Command &&
defaultBinding.Comment == confBinding.Comment)
{
defaultBinding.Input = confBinding.Input;
removed.Add(confBinding);
}
}
}
foreach (Binding binding in removed)
{
conf.Remove(binding);
}
defaults.AddRange(conf);
return InputHelp.ConvertToString(defaults);

View File

@@ -1,13 +1,4 @@

using CommunityToolkit.Mvvm.Messaging.Messages;
namespace MpvNet.MVVM;
public class MainWindowIsLoadedMessage { }
//public class ScaleWindowMessage : ValueChangedMessage<float>
//{
// public ScaleWindowMessage(float value) : base(value)
// {
// }
//}

View File

@@ -21,11 +21,11 @@ public class MpvClient
public event Action? Seek; // seek MPV_EVENT_SEEK
public event Action? PlaybackRestart; // playback-restart MPV_EVENT_PLAYBACK_RESTART
public Dictionary<string, List<Action>> PropChangeActions { get; set; } = new Dictionary<string, List<Action>>();
public Dictionary<string, List<Action<int>>> IntPropChangeActions { get; set; } = new Dictionary<string, List<Action<int>>>();
public Dictionary<string, List<Action<bool>>> BoolPropChangeActions { get; set; } = new Dictionary<string, List<Action<bool>>>();
public Dictionary<string, List<Action<double>>> DoublePropChangeActions { get; set; } = new Dictionary<string, List<Action<double>>>();
public Dictionary<string, List<Action<string>>> StringPropChangeActions { get; set; } = new Dictionary<string, List<Action<string>>>();
public Dictionary<string, List<Action>> PropChangeActions { get; set; } = [];
public Dictionary<string, List<Action<int>>> IntPropChangeActions { get; set; } = [];
public Dictionary<string, List<Action<bool>>> BoolPropChangeActions { get; set; } = [];
public Dictionary<string, List<Action<double>>> DoublePropChangeActions { get; set; } = [];
public Dictionary<string, List<Action<string>>> StringPropChangeActions { get; set; } = [];
public nint Handle { get; set; }
@@ -132,46 +132,72 @@ public class MpvClient
else if (data.format == mpv_format.MPV_FORMAT_STRING)
{
lock (StringPropChangeActions)
{
foreach (var pair in StringPropChangeActions)
{
if (pair.Key == data.name)
{
string value = ConvertFromUtf8(Marshal.PtrToStructure<IntPtr>(data.data));
foreach (var action in pair.Value)
{
action.Invoke(value);
}
}
}
}
}
else if (data.format == mpv_format.MPV_FORMAT_INT64)
{
lock (IntPropChangeActions)
{
foreach (var pair in IntPropChangeActions)
{
if (pair.Key == data.name)
{
int value = Marshal.PtrToStructure<int>(data.data);
foreach (var action in pair.Value)
{
action.Invoke(value);
}
}
}
}
}
else if (data.format == mpv_format.MPV_FORMAT_NONE)
{
lock (PropChangeActions)
{
foreach (var pair in PropChangeActions)
{
if (pair.Key == data.name)
{
foreach (var action in pair.Value)
{
action.Invoke();
}
}
}
}
}
else if (data.format == mpv_format.MPV_FORMAT_DOUBLE)
{
lock (DoublePropChangeActions)
{
foreach (var pair in DoublePropChangeActions)
{
if (pair.Key == data.name)
{
double value = Marshal.PtrToStructure<double>(data.data);
foreach (var action in pair.Value)
{
action.Invoke(value);
}
}
}
}
}
}
@@ -247,7 +273,9 @@ public class MpvClient
mpv_error err = mpv_command_ret(Handle, rootPtr, resultNodePtr);
foreach (IntPtr ptr in pointers)
{
Marshal.FreeHGlobal(ptr);
}
Marshal.FreeHGlobal(rootPtr);
@@ -409,7 +437,7 @@ public class MpvClient
if (err < 0)
HandleError(err, "error observing property: " + name);
else
IntPropChangeActions[name] = new List<Action<int>>();
IntPropChangeActions[name] = [];
}
if (IntPropChangeActions.ContainsKey(name))
@@ -428,7 +456,7 @@ public class MpvClient
if (err < 0)
HandleError(err, "error observing property: " + name);
else
DoublePropChangeActions[name] = new List<Action<double>>();
DoublePropChangeActions[name] = [];
}
if (DoublePropChangeActions.ContainsKey(name))
@@ -447,7 +475,7 @@ public class MpvClient
if (err < 0)
HandleError(err, "error observing property: " + name);
else
BoolPropChangeActions[name] = new List<Action<bool>>();
BoolPropChangeActions[name] = [];
}
if (BoolPropChangeActions.ContainsKey(name))
@@ -466,7 +494,7 @@ public class MpvClient
if (err < 0)
HandleError(err, "error observing property: " + name);
else
StringPropChangeActions[name] = new List<Action<string>>();
StringPropChangeActions[name] = [];
}
if (StringPropChangeActions.ContainsKey(name))
@@ -485,7 +513,7 @@ public class MpvClient
if (err < 0)
HandleError(err, "error observing property: " + name);
else
PropChangeActions[name] = new List<Action>();
PropChangeActions[name] = [];
}
if (PropChangeActions.ContainsKey(name))

View File

@@ -1,27 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>libmpvnet</AssemblyName>
<Product>mpv.net</Product>
<Nullable>enable</Nullable>
<RootNamespace>MpvNet</RootNamespace>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\docs\changelog.md" Link="Docs\changelog.md" />
<None Include="..\..\docs\manual.md" Link="Docs\manual.md" />
<None Include="..\..\README.md" Link="Docs\README.md" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\docs\changelog.md" Link="Docs\changelog.md" />
<None Include="..\..\docs\manual.md" Link="Docs\manual.md" />
<None Include="..\..\README.md" Link="Docs\README.md" />
</ItemGroup>
<ItemGroup>
<Folder Include="Docs\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Docs\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="NGettext" Version="0.6.7" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" />
<PackageReference Include="NGettext" />
</ItemGroup>
</Project>

View File

@@ -73,10 +73,12 @@ public class MainPlayer : MpvClient
MainHandle = mpv_create();
Handle = MainHandle;
var events = Enum.GetValues(typeof(mpv_event_id)).Cast<mpv_event_id>();
var events = Enum.GetValues<mpv_event_id>().Cast<mpv_event_id>();
foreach (mpv_event_id i in events)
{
mpv_request_event(MainHandle, i, 0);
}
mpv_request_log_messages(MainHandle, "no");
@@ -194,7 +196,9 @@ public class MainPlayer : MpvClient
mpv_destroy(Handle);
foreach (var client in Clients)
{
mpv_destroy(client.Handle);
}
}
public void ProcessProperty(string? name, string? value)
@@ -263,6 +267,8 @@ public class MainPlayer : MpvClient
}
}
private readonly Regex ConfRegex = new Regex("^[\\w-]+$", RegexOptions.Compiled);
Dictionary<string, string>? _Conf;
public Dictionary<string, string> Conf {
@@ -273,7 +279,7 @@ public class MainPlayer : MpvClient
App.ApplyInputDefaultBindingsFix();
_Conf = new Dictionary<string, string>();
_Conf = [];
if (File.Exists(ConfPath))
{
@@ -281,12 +287,12 @@ public class MainPlayer : MpvClient
{
string line = it.TrimStart(' ', '-').TrimEnd();
if (line.StartsWith("#"))
if (line.StartsWith('#'))
continue;
if (!line.Contains('='))
{
if (Regex.Match(line, "^[\\w-]+$").Success)
if (ConfRegex.Match(line).Success)
line += "=yes";
else
continue;
@@ -305,7 +311,9 @@ public class MainPlayer : MpvClient
}
foreach (var i in _Conf)
{
ProcessProperty(i.Key, i.Value);
}
return _Conf;
}
@@ -331,7 +339,9 @@ public class MainPlayer : MpvClient
public void MainEventLoop()
{
while (true)
{
mpv_wait_event(MainHandle, -1);
}
}
protected override void OnShutdown()
@@ -479,14 +489,14 @@ public class MainPlayer : MpvClient
Command("stop");
Thread.Sleep(500);
SetPropertyString("dvd-device", path);
LoadFiles(new[] { @"dvd://" }, false, false);
LoadFiles([@"dvd://"], false, false);
}
else
{
Command("stop");
Thread.Sleep(500);
SetPropertyString("bluray-device", path);
LoadFiles(new[] { @"bd://" }, false, false);
LoadFiles([@"bd://"], false, false);
}
}
@@ -498,12 +508,12 @@ public class MainPlayer : MpvClient
if (Directory.Exists(path + "\\BDMV"))
{
SetPropertyString("bluray-device", path);
LoadFiles(new[] { @"bd://" }, false, false);
LoadFiles([@"bd://"], false, false);
}
else
{
SetPropertyString("dvd-device", path);
LoadFiles(new[] { @"dvd://" }, false, false);
LoadFiles([@"dvd://"], false, false);
}
}
@@ -601,8 +611,10 @@ public class MainPlayer : MpvClient
static string GetNativeLanguage(string name)
{
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
{
if (ci.EnglishName == name)
return ci.NativeName;
}
return name;
}
@@ -629,7 +641,7 @@ public class MainPlayer : MpvClient
if (_audioDevices != null)
return _audioDevices;
_audioDevices = new();
_audioDevices = [];
string json = GetPropertyString("audio-device-list");
var enumerator = JsonDocument.Parse(json).RootElement.EnumerateArray();
@@ -680,6 +692,8 @@ public class MainPlayer : MpvClient
}
}
private readonly Regex TitleRegex = new Regex(@"^[\._\-]", RegexOptions.Compiled);
public List<MediaTrack> GetTracks(bool includeInternal = true, bool includeExternal = true)
{
List<MediaTrack> tracks = new List<MediaTrack>();
@@ -697,7 +711,7 @@ public class MainPlayer : MpvClient
string filename = GetPropertyString($"filename/no-ext");
string title = GetPropertyString($"track-list/{i}/title").Replace(filename, "");
title = Regex.Replace(title, @"^[\._\-]", "");
title = TitleRegex.Replace(title, "");
if (type == "video")
{
@@ -1043,7 +1057,7 @@ public class MainPlayer : MpvClient
if (_profileNames != null)
return _profileNames;
string[] ignore = { "builtin-pseudo-gui", "encoding", "libmpv", "pseudo-gui", "default" };
string[] ignore = ["builtin-pseudo-gui", "encoding", "libmpv", "pseudo-gui", "default"];
string json = GetPropertyString("profile-list");
return _profileNames = JsonDocument.Parse(json).RootElement.EnumerateArray()
.Select(it => it.GetProperty("name").GetString())

View File

@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net9.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
<PackageReference Include="NGettext" Version="0.6.7" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" />
<PackageReference Include="NGettext" />
</ItemGroup>
</Project>

View File

@@ -40,7 +40,7 @@ Test (Join-Path $SourceDir 'MpvNet.sln')
$7zFile = Test 'C:\Program Files\7-Zip\7z.exe'
$InnoSetupCompiler = Test 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe'
$ReleaseNotes = "- [.NET Desktop Runtime 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)`n- [Changelog](https://github.com/mpvnet-player/mpv.net/blob/main/docs/changelog.md)"
$ReleaseNotes = "- [.NET Desktop Runtime 9.0](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)`n- [Changelog](https://github.com/mpvnet-player/mpv.net/blob/main/docs/changelog.md)"
$Repo = 'github.com/mpvnet-player/mpv.net'
# Dotnet Publish