Improved conf file reader/writer.
@@ -1,7 +1,11 @@
|
||||
|
||||
# v7.0.0.3 Beta (2023-??-??)
|
||||
|
||||
- mpv.net can no longer be downloaded from the Microsoft store due
|
||||
to a general very poor experience with the package creation and submission.
|
||||
This means winget download support is unavailable until a new winget solution is implemented.
|
||||
- New menu item added at Settings/Setup to add mpv.net to the path environment variable.
|
||||
- Improved conf file reader/writer.
|
||||
|
||||
# v7.0.0.2 Beta (2023-12-13)
|
||||
|
||||
|
||||
@@ -23,3 +23,6 @@ dotnet_diagnostic.IDE0044.severity = silent
|
||||
|
||||
# Member does not access instance data and can be marked as static
|
||||
dotnet_diagnostic.CA1822.severity = none
|
||||
|
||||
# IDE0057: Use range operator
|
||||
csharp_style_prefer_range_operator = false
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
@@ -131,7 +132,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
if (setting.Name == confItem.Name && confItem.Section == "" && !confItem.IsSectionItem)
|
||||
{
|
||||
setting.Value = confItem.Value.Trim('\'', '"');
|
||||
setting.Value = confItem.Value;
|
||||
setting.StartValue = setting.Value;
|
||||
setting.ConfItem = confItem;
|
||||
confItem.SettingBase = setting;
|
||||
@@ -221,14 +222,10 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
string line = currentLine.Trim();
|
||||
|
||||
if (line == "")
|
||||
{
|
||||
comment += "\r\n";
|
||||
}
|
||||
else if (line.StartsWith("#"))
|
||||
{
|
||||
comment += line.Trim() + "\r\n";
|
||||
}
|
||||
else if (line.StartsWith("[") && line.Contains("]"))
|
||||
else if (line.StartsWith("[") && line.Contains(']'))
|
||||
{
|
||||
if (!isSectionItem && comment != "" && comment != "\r\n")
|
||||
ConfItems.Add(new ConfItem() {
|
||||
@@ -238,8 +235,11 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
comment = "";
|
||||
isSectionItem = true;
|
||||
}
|
||||
else if (line.Contains("="))
|
||||
else if (line.Contains('=') || Regex.Match(line, "^[\\w-]+$").Success)
|
||||
{
|
||||
if (!line.Contains('='))
|
||||
line += "=yes";
|
||||
|
||||
ConfItem item = new ConfItem();
|
||||
item.File = Path.GetFileNameWithoutExtension(file);
|
||||
item.IsSectionItem = isSectionItem;
|
||||
@@ -248,15 +248,21 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
item.Section = section;
|
||||
section = "";
|
||||
|
||||
if (line.Contains("#") && !line.Contains("'") && !line.Contains("\""))
|
||||
if (line.Contains('#') && !line.Contains("'") && !line.Contains("\""))
|
||||
{
|
||||
item.LineComment = line.Substring(line.IndexOf("#")).Trim();
|
||||
line = line.Substring(0, line.IndexOf("#")).Trim();
|
||||
}
|
||||
|
||||
int pos = line.IndexOf("=");
|
||||
string left = line.Substring(0, pos).Trim().ToLower();
|
||||
string left = line.Substring(0, pos).Trim().ToLower().TrimStart('-');
|
||||
string right = line.Substring(pos + 1).Trim();
|
||||
|
||||
if (right.StartsWith('\'') && right.EndsWith('\''))
|
||||
right = right.Trim('\'');
|
||||
|
||||
if (right.StartsWith('"') && right.EndsWith('"'))
|
||||
right = right.Trim('"');
|
||||
|
||||
if (left == "fs")
|
||||
left = "fullscreen";
|
||||
@@ -271,6 +277,23 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
string EscapeValue(string value)
|
||||
{
|
||||
if (value.Contains('\''))
|
||||
return '"' + value + '"';
|
||||
|
||||
if (value.Contains('"'))
|
||||
return '\'' + value + '\'';
|
||||
|
||||
if (value.Contains('"') || value.Contains('#') || value.StartsWith("%") ||
|
||||
value.StartsWith(" ") || value.EndsWith(" "))
|
||||
{
|
||||
return '\'' + value + '\'';
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
string GetContent(string filename)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -288,7 +311,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
if (item.Name != "")
|
||||
{
|
||||
sb.Append(item.Name + " = " + item.Value);
|
||||
sb.Append(item.Name + " = " + EscapeValue(item.Value));
|
||||
|
||||
if (item.LineComment != "")
|
||||
sb.Append(" " + item.LineComment);
|
||||
@@ -299,17 +322,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
}
|
||||
else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default)
|
||||
{
|
||||
string? value;
|
||||
|
||||
if (item.SettingBase.Type == "string" ||
|
||||
item.SettingBase.Type == "folder" ||
|
||||
item.SettingBase.Type == "color")
|
||||
|
||||
value = "'" + item.SettingBase.Value + "'";
|
||||
else
|
||||
value = item.SettingBase.Value;
|
||||
|
||||
sb.Append(item.Name + " = " + value);
|
||||
sb.Append(item.Name + " = " + EscapeValue(item.SettingBase.Value!));
|
||||
|
||||
if (item.LineComment != "")
|
||||
sb.Append(" " + item.LineComment);
|
||||
@@ -325,19 +338,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
continue;
|
||||
|
||||
if ((setting.Value ?? "") != setting.Default)
|
||||
{
|
||||
string? value;
|
||||
|
||||
if (setting.Type == "string" ||
|
||||
setting.Type == "folder" ||
|
||||
setting.Type == "color")
|
||||
|
||||
value = "'" + setting.Value + "'";
|
||||
else
|
||||
value = setting.Value;
|
||||
|
||||
sb.AppendLine(setting.Name + " = " + value);
|
||||
}
|
||||
sb.AppendLine(setting.Name + " = " + EscapeValue(setting.Value!));
|
||||
}
|
||||
|
||||
foreach (ConfItem item in ConfItems)
|
||||
@@ -356,7 +357,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
if (item.Comment != "")
|
||||
sb.Append(item.Comment);
|
||||
|
||||
sb.Append(item.Name + " = " + item.Value);
|
||||
sb.Append(item.Name + " = " + EscapeValue(item.Value));
|
||||
|
||||
if (item.LineComment != "")
|
||||
sb.Append(" " + item.LineComment);
|
||||
|
||||
@@ -268,38 +268,47 @@ public class MainPlayer : MpvClient
|
||||
Dictionary<string, string>? _Conf;
|
||||
|
||||
public Dictionary<string, string> Conf {
|
||||
get {
|
||||
if (_Conf == null)
|
||||
get
|
||||
{
|
||||
if (_Conf != null)
|
||||
return _Conf;
|
||||
|
||||
App.ApplyInputDefaultBindingsFix();
|
||||
|
||||
_Conf = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(ConfPath))
|
||||
{
|
||||
App.ApplyInputDefaultBindingsFix();
|
||||
|
||||
_Conf = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(ConfPath))
|
||||
foreach (string? it in File.ReadAllLines(ConfPath))
|
||||
{
|
||||
foreach (string? it in File.ReadAllLines(ConfPath))
|
||||
string line = it.TrimStart(' ', '-').TrimEnd();
|
||||
|
||||
if (line.StartsWith("#"))
|
||||
continue;
|
||||
|
||||
if (!line.Contains('='))
|
||||
{
|
||||
string line = it.TrimStart(' ', '-').TrimEnd();
|
||||
|
||||
if (!line.Contains('=') || line.StartsWith("#"))
|
||||
if (Regex.Match(line, "^[\\w-]+$").Success)
|
||||
line += "=yes";
|
||||
else
|
||||
continue;
|
||||
|
||||
string key = line[..line.IndexOf("=")].Trim();
|
||||
string value = line[(line.IndexOf("=") + 1)..].Trim();
|
||||
|
||||
if (value.Contains('#') && !value.StartsWith("#") &&
|
||||
!value.StartsWith("'#") && !value.StartsWith("\"#"))
|
||||
|
||||
value = value[..value.IndexOf("#")].Trim();
|
||||
|
||||
_Conf[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var i in _Conf)
|
||||
ProcessProperty(i.Key, i.Value);
|
||||
string key = line[..line.IndexOf("=")].Trim();
|
||||
string value = line[(line.IndexOf("=") + 1)..].Trim();
|
||||
|
||||
if (value.Contains('#') && !value.StartsWith("#") &&
|
||||
!value.StartsWith("'#") && !value.StartsWith("\"#"))
|
||||
|
||||
value = value[..value.IndexOf("#")].Trim();
|
||||
|
||||
_Conf[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var i in _Conf)
|
||||
ProcessProperty(i.Key, i.Value);
|
||||
|
||||
return _Conf;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 11 KiB |
@@ -1,73 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '15.0'">
|
||||
<VisualStudioVersion>15.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>81daee3a-76ff-4494-9384-d28a651d70bb</ProjectGuid>
|
||||
<TargetPlatformVersion>10.0.22000.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
|
||||
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
|
||||
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
|
||||
<GenerateTestArtifacts>True</GenerateTestArtifacts>
|
||||
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
|
||||
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
|
||||
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
|
||||
<EntryPointProjectUniqueName>..\MpvNet.Windows\MpvNet.Windows.csproj</EntryPointProjectUniqueName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<AppxBundle>Always</AppxBundle>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<AppxBundle>Always</AppxBundle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\MpvNet.Windows\bin\Debug\libmpv-2.dll">
|
||||
<Link>libmpv-2.dll</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\MpvNet.Windows\bin\Debug\MediaInfo.dll">
|
||||
<Link>MediaInfo.dll</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\MpvNet.Windows\bin\Debug\mpvnet.com">
|
||||
<Link>mpvnet.com</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Images\SplashScreen.scale-200.png" />
|
||||
<Content Include="Images\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Images\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Images\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Images\StoreLogo.png" />
|
||||
<Content Include="Images\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MpvNet.Windows\MpvNet.Windows.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,137 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
|
||||
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
IgnorableNamespaces="uap rescap">
|
||||
|
||||
<Identity
|
||||
Name="5664FrankSkare.mpv.net"
|
||||
Publisher="CN=6A1A1E69-736C-4C77-B310-7B6D38E32617"
|
||||
Version="6.0.3.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>mpv.net</DisplayName>
|
||||
<PublisherDisplayName>Frank Skare</PublisherDisplayName>
|
||||
<Logo>Images\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="$targetentrypoint$">
|
||||
<uap:VisualElements
|
||||
DisplayName="mpv.net"
|
||||
Description="mpv.net is a modern media player based on the popular mpv player."
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Images\Square150x150Logo.png"
|
||||
Square44x44Logo="Images\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
|
||||
<uap:SplashScreen Image="Images\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
|
||||
<Extensions>
|
||||
<uap3:Extension Category="windows.appExecutionAlias">
|
||||
<uap3:AppExecutionAlias>
|
||||
<desktop:ExecutionAlias Alias="MpvNet.exe" />
|
||||
</uap3:AppExecutionAlias>
|
||||
</uap3:Extension>
|
||||
|
||||
<uap:Extension Category="windows.fileTypeAssociation">
|
||||
<uap:FileTypeAssociation Name="videotypes">
|
||||
<uap:SupportedFileTypes>
|
||||
<uap:FileType>.264</uap:FileType>
|
||||
<uap:FileType>.265</uap:FileType>
|
||||
<uap:FileType>.asf</uap:FileType>
|
||||
<uap:FileType>.avc</uap:FileType>
|
||||
<uap:FileType>.avi</uap:FileType>
|
||||
<uap:FileType>.avs</uap:FileType>
|
||||
<uap:FileType>.dav</uap:FileType>
|
||||
<uap:FileType>.flv</uap:FileType>
|
||||
<uap:FileType>.h264</uap:FileType>
|
||||
<uap:FileType>.h265</uap:FileType>
|
||||
<uap:FileType>.hevc</uap:FileType>
|
||||
<uap:FileType>.m2t</uap:FileType>
|
||||
<uap:FileType>.m2ts</uap:FileType>
|
||||
<uap:FileType>.m2v</uap:FileType>
|
||||
<uap:FileType>.m4v</uap:FileType>
|
||||
<uap:FileType>.mkv</uap:FileType>
|
||||
<uap:FileType>.mov</uap:FileType>
|
||||
<uap:FileType>.mp4</uap:FileType>
|
||||
<uap:FileType>.mpeg</uap:FileType>
|
||||
<uap:FileType>.mpg</uap:FileType>
|
||||
<uap:FileType>.mpv</uap:FileType>
|
||||
<uap:FileType>.mts</uap:FileType>
|
||||
<uap:FileType>.ts</uap:FileType>
|
||||
<uap:FileType>.vob</uap:FileType>
|
||||
<uap:FileType>.vpy</uap:FileType>
|
||||
<uap:FileType>.webm</uap:FileType>
|
||||
<uap:FileType>.wmv</uap:FileType>
|
||||
<uap:FileType>.y4m</uap:FileType>
|
||||
</uap:SupportedFileTypes>
|
||||
</uap:FileTypeAssociation>
|
||||
</uap:Extension>
|
||||
|
||||
<uap:Extension Category="windows.fileTypeAssociation">
|
||||
<uap:FileTypeAssociation Name="audiotypes">
|
||||
<uap:SupportedFileTypes>
|
||||
<uap:FileType>.aac</uap:FileType>
|
||||
<uap:FileType>.ac3</uap:FileType>
|
||||
<uap:FileType>.dts</uap:FileType>
|
||||
<uap:FileType>.dtshd</uap:FileType>
|
||||
<uap:FileType>.dtshr</uap:FileType>
|
||||
<uap:FileType>.dtsma</uap:FileType>
|
||||
<uap:FileType>.eac3</uap:FileType>
|
||||
<uap:FileType>.flac</uap:FileType>
|
||||
<uap:FileType>.m4a</uap:FileType>
|
||||
<uap:FileType>.mka</uap:FileType>
|
||||
<uap:FileType>.mp2</uap:FileType>
|
||||
<uap:FileType>.mp3</uap:FileType>
|
||||
<uap:FileType>.mpa</uap:FileType>
|
||||
<uap:FileType>.mpc</uap:FileType>
|
||||
<uap:FileType>.ogg</uap:FileType>
|
||||
<uap:FileType>.opus</uap:FileType>
|
||||
<uap:FileType>.thd</uap:FileType>
|
||||
<uap:FileType>.w64</uap:FileType>
|
||||
<uap:FileType>.wav</uap:FileType>
|
||||
</uap:SupportedFileTypes>
|
||||
</uap:FileTypeAssociation>
|
||||
</uap:Extension>
|
||||
|
||||
<uap:Extension Category="windows.protocol">
|
||||
<uap:Protocol Name="ytdl" />
|
||||
</uap:Extension>
|
||||
|
||||
<uap:Extension Category="windows.protocol">
|
||||
<uap:Protocol Name="rtsp" />
|
||||
</uap:Extension>
|
||||
|
||||
<uap:Extension Category="windows.protocol">
|
||||
<uap:Protocol Name="srt" />
|
||||
</uap:Extension>
|
||||
|
||||
<uap:Extension Category="windows.protocol">
|
||||
<uap:Protocol Name="srtp" />
|
||||
</uap:Extension>
|
||||
</Extensions>
|
||||
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||