Firemonkey de idhttp ile dosya indiriyorum fakat work end eventı iki kere çalışıyor.
Hem bitmeden hemde bittikten sonra.
Kod: Tümünü seç
TThread.CreateAnonymousThread(
procedure
var
ms : TMemoryStream;
begin
ms:=TMemoryStream.Create;
sHTTP.Get('https://api.soundcloud.com/tracks/'+lstDown.ListItems[sIndex - 1].ItemData.Detail +
'/stream?client_id=9a9c7c875b0ab4d0c254ccc9a14c61e4',ms);
ms.Seek(0,0);
if not DirectoryExists(TPath.GetSharedMusicPath + PathDelim + 'Extremity') then
CreateDir(TPath.GetSharedMusicPath + PathDelim + 'Extremity');
ms.SaveToFile(TPath.GetSharedMusicPath + PathDelim + 'Extremity' +PathDelim + lstDown.Items[sIndex - 1] + '.mp3');
ms.Free;
end).Start;