Implemented tag refresh on a playlist. Made audio file scanning truly asynchronous. Added basic playlist sorting functionality.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user