Code: Selecteer alles
PAL.Loop := True;
PAL.LockExecution;
var AQuery : TDataSet;
var Song : TSongInfo;
AQuery := Query('SELECT songlist.*, requestlist.*, requestlist.ID as requestID '
+' FROM songlist, requestlist '
+' WHERE (requestlist.ETA<:now) AND (requestlist.status=''new'') AND (songlist.ID=requestlist.songID) '
+ 'ORDER BY requestlist.ETA ASC '
+' LIMIT 1 ',[Now],True);
if not(AQuery.BOF and AQuery.EOF) then
begin
Song := TSongInfo.Create();
Song['ID'] := AQuery['ID'];
Song['filename'] := AQuery['filename'];
Song['artist'] := AQuery['artist'];
Song['title'] := AQuery['title'];
Song['duration'] := AQuery['duration'];
Song['requestID'] := AQuery['requestID'];
Queue.Add(Song,ipTop); //iptop hij zet hem boven aan queue , ip bottom hij zet hem onderaan
WriteLn('Request handled: '+Song['artist']+' - '+Song['title']);
ExecSQL('UPDATE requestlist SET status=:status WHERE (songID = :songID) AND ((status=''new'') OR (status=''pending'')) ',['pending',song['ID']]);
AQuery.Free;
Song.Free;
end
else
WriteLn('No request found');
PAL.UnLockExecution;
PAL.WaitForPlayCount(1); // hij wacht 2 nummer(1 request+1van programmering)
