Implemented tag refresh on a playlist. Made audio file scanning truly asynchronous. Added basic playlist sorting functionality.

This commit is contained in:
2026-08-02 23:34:04 -04:00
parent 7aaf36f7b2
commit 99978c62c4
7 changed files with 191 additions and 36 deletions

View File

@@ -9,22 +9,19 @@ public class AudioFileScanner(IAudioEngine audioEngine, ITagResolver tagResolver
{
public async Task<Song[]> GetSongsAsync(string[] fileNames, CancellationToken cancellationToken)
{
List<Song> songs = [];
Song?[] songs = new Song?[fileNames.Length];
foreach (string fileName in fileNames)
await Parallel.ForEachAsync(Enumerable.Range(0, fileNames.Length), cancellationToken, async (index, token) =>
{
string fileName = fileNames[index];
if (string.IsNullOrWhiteSpace(fileName) || File.Exists(fileName) == false)
continue;
return;
Song? song = await GetSongAsync(fileName, cancellationToken);
songs[index] = await GetSongAsync(fileName, token);
});
if (song == null)
continue;
songs.Add(song);
}
return [.. songs];
return [.. songs.Where(song => song != null)!];
}
private async Task<Song> GetSongAsync(string fileName, CancellationToken cancellationToken)