procedure ScanMP3Folder (const AFolder : string; AMP3List : TStrings);
var
ds : TDirectoryScanner;
a : TAudioInfo;
Descr : string;
i : integer;
begin
ds := TDirectoryScanner.Create;
a := TAudioInfo.Create;
try
ds.Recursive := True;
ds.RegExprMask := '\.mp[23]';
ds.BuildFileList (AFolder);
for i := 0 to ds.Count - 1 do
begin
a.LoadFromFile (ds.Item [i].name);
if a.ID3.Ok then
Descr := a.ID3.Artist + ' - ' + a.ID3.Title
else
Descr := ExtractFileName (ds.Item [i].name);
Descr := Descr + Format (' (%d sec)', [a.MpegDuration div 1000]);
AMP3List.Add (Descr);
end;
finally
begin
a.Free;
ds.Free;
end;
end;
end;