Skip to content

Commit

Permalink
Remove Windows version check from SupportedFileTypes; Win10 is minimu…
Browse files Browse the repository at this point in the history
…m required
  • Loading branch information
jbe2277 committed Nov 25, 2023
1 parent 22fc820 commit fde1c96
Showing 1 changed file with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Waf.MusicManager.Presentation.Services;

internal static class SupportedFileTypes
{
private static readonly string[] musicFileExtensions = [ ".mp3", ".wma", ".wav", ".m4a", ".mp4" ];

private static readonly Mp3ReadMetadata mp3ReadMetadata = new();
private static readonly WmaReadMetadata wmaReadMetadata = new();
private static readonly AacReadMetadata aacReadMetadata = new();
Expand All @@ -23,14 +21,10 @@ internal static class SupportedFileTypes
private static readonly FlacSaveMetadata flacSaveMetadata = new();
private static readonly MkvSaveMetadata mkvSaveMetadata = new();

public static IReadOnlyList<string> MusicFileExtensions => AddMoreExtensionsWhenSupported(musicFileExtensions);
public static IReadOnlyList<string> MusicFileExtensions => [".mp3", ".wma", ".wav", ".m4a", ".mp4", ".flac", ".mkv"];

public static IReadOnlyList<string> PlaylistFileExtensions => IFileService.PlaylistFileExtensions;

private static bool IsFlacSupported => Environment.OSVersion.Version.Major >= 10;

private static bool IsMkvSupported => Environment.OSVersion.Version.Major >= 10;

internal static ReadMetadata GetReadMetadata(string fileExtension)
{
if (fileExtension.Equals(".mp3", StringComparison.OrdinalIgnoreCase))
Expand All @@ -53,11 +47,11 @@ internal static ReadMetadata GetReadMetadata(string fileExtension)
{
return mp4ReadMetadata;
}
else if (IsFlacSupported && fileExtension.Equals(".flac", StringComparison.OrdinalIgnoreCase))
else if (fileExtension.Equals(".flac", StringComparison.OrdinalIgnoreCase))
{
return flacReadMetadata;
}
else if (IsMkvSupported && fileExtension.Equals(".mkv", StringComparison.OrdinalIgnoreCase))
else if (fileExtension.Equals(".mkv", StringComparison.OrdinalIgnoreCase))
{
return mkvReadMetadata;
}
Expand Down Expand Up @@ -89,11 +83,11 @@ internal static SaveMetadata GetSaveMetadata(string fileExtension)
{
return mp4SaveMetadata;
}
else if (IsFlacSupported && fileExtension.Equals(".flac", StringComparison.OrdinalIgnoreCase))
else if (fileExtension.Equals(".flac", StringComparison.OrdinalIgnoreCase))
{
return flacSaveMetadata;
}
else if (IsMkvSupported && fileExtension.Equals(".mkv", StringComparison.OrdinalIgnoreCase))
else if (fileExtension.Equals(".mkv", StringComparison.OrdinalIgnoreCase))
{
return mkvSaveMetadata;
}
Expand All @@ -102,12 +96,4 @@ internal static SaveMetadata GetSaveMetadata(string fileExtension)
throw new NotSupportedException("The provided extension '" + fileExtension + "' is not supported.");
}
}

private static IReadOnlyList<string> AddMoreExtensionsWhenSupported(IReadOnlyList<string> extensions)
{
IEnumerable<string> result = extensions;
if (IsFlacSupported) result = result.Concat([ ".flac" ]);
if (IsMkvSupported) result = result.Concat([ ".mkv" ]);
return result.ToArray();
}
}

0 comments on commit fde1c96

Please sign in to comment.