PAL.Loop := True; PAL.WaitForQueue(0); var Q : TDataSet; var looper,NumSongs : Integer; var Artist1,Artist2,Artist3,Artist4,Song1,Song2,Song3,Song4,JingleIntro,JingleOutro : String; var ListaIds : String ='0'; //tolto il 76 che era la musica classica tra il 31 e il 60 var OrdineCategorie : Array of Integer = [82,80,17,32,49,17,42,15,17,28,57,17,40,67,17,25,58,17,30,50,17,37,56,17,38,64,17,87,23,17,47,24,17,55,27,17,59,35,17,52,43,17,46,94,17,29,51,17,36,48,17,41,75,17,31,60,17,39,83,17,63,42,17,62,34,17,53,20,17,45,22,17,66,19,17,14,26,17,44,21,17,54,85,17,84,92,17,93]; //rock e pop var ListaCategorie1 : String = '61,65'; //50s,60s,70s,80s,90s,dance,darkgrunge,hardrock,italian,rnb,rockprogressive,synthpop,emo,tedesco,svedese,ucraino var ListaCategorie2 : String = '46,47,48,49,50,51,52,55,56,57,64,66,67,80,23,42,82'; //seleziono canzone pop Q := Query('SELECT songlist.id,artist,filename FROM songlist left join categorylist on categorylist.songid=songlist.id where categoryID=61 order by date_played limit 0,1',[],True); Q.First; while not Q.EOF do begin ListaIds:=ListaIds+','+IntToStr(Q['id']); Queue.AddFile(Q['filename'],ipBottom); Q.Next; end; Q.Free; //seleziono canzone rock Q := Query('SELECT songlist.id,artist,filename FROM songlist left join categorylist on categorylist.songid=songlist.id where categoryID=65 order by date_played limit 0,1',[],True); Q.First; while not Q.EOF do begin ListaIds:=ListaIds+','+IntToStr(Q['id']); Queue.AddFile(Q['filename'],ipBottom); Q.Next; end; Q.Free; //inizio categoria scelta for looper := 0 to OrdineCategorie.length-1 do begin NumSongs:=0;JingleOutro:='';JingleIntro:=''; Q := Query('SELECT * from category where ID='+IntToStr(OrdineCategorie[looper]),[],True); Q.First; while not Q.EOF do begin JingleIntro:=Q['introjingle']; JingleOutro:=Q['outrojingle']; NumSongs:=Q['numsongs']; WriteLn(Q['nomeitaliano']); Q.Next; end; Q.Free; Queue.AddFile(JingleIntro,ipBottom); Artist1:='';Artist2:='';Artist3:='';Artist4:=''; Q := Query('SELECT songlist.id,artist,filename FROM songlist left join categorylist on categorylist.songid=songlist.id where categoryID='+IntToStr(OrdineCategorie[looper])+' and songlist.id not in ('+ListaIds+') order by date_played limit 0,1',[],True); Q.First; while not Q.EOF do begin Artist1:=Q['artist']; ListaIds:=ListaIds+','+IntToStr(Q['id']); Queue.AddFile(Q['filename'],ipBottom); Q.Next; end; Q.Free; if(NumSongs>1) then begin Q := Query('SELECT songlist.id,artist,filename FROM songlist left join categorylist on categorylist.songid=songlist.id where categoryID='+IntToStr(OrdineCategorie[looper])+' and songlist.id not in ('+ListaIds+') and artist <>'+QuotedStr(Artist1)+' order by date_played limit 0,1',[],True); Q.First; while not Q.EOF do begin Artist2:=Q['artist']; ListaIds:=ListaIds+','+IntToStr(Q['id']); Queue.AddFile(Q['filename'],ipBottom); Q.Next; end; Q.Free; Q := Query('SELECT songlist.id,artist,filename FROM songlist left join categorylist on categorylist.songid=songlist.id where categoryID='+IntToStr(OrdineCategorie[looper])+' and songlist.id not in ('+ListaIds+') and artist <>'+QuotedStr(Artist1)+' and artist <>'+QuotedStr(Artist2)+' order by date_played limit 0,1',[],True); Q.First; while not Q.EOF do begin ListaIds:=ListaIds+','+IntToStr(Q['id']); Queue.AddFile(Q['filename'],ipBottom); Q.Next; end; Q.Free; end; Queue.AddFile(JingleOutro,ipBottom); //seleziono 2 canzoni casuali cateogrie1 Song1:='';Song2:='';Song3:='';Song4:=''; Q := Query('SELECT songlist.id,filename FROM songlist left join categorylist on categorylist.songid=songlist.id where categoryID in ('+ListaCategorie1+') and categoryID not in ('+IntToStr(OrdineCategorie[looper])+') and artist<>'+QuotedStr(Artist3)+' and songlist.id not in ('+ListaIds+') order by rand() limit 0,2',[],True); Q.First; while not Q.EOF do begin Song1:=Q['filename']; if (Song3='') then Song3:=Q['filename']; Artist3:=Q['artist']; ListaIds:=ListaIds+','+IntToStr(Q['id']); Q.Next; end; Q.Free; //seleziono 2 canzoni casuali cateogrie2 Q := Query('SELECT songlist.id,filename FROM songlist left join categorylist on categorylist.songid=songlist.id where categoryID in ('+ListaCategorie2+') and categoryID not in ('+IntToStr(OrdineCategorie[looper])+') and artist<>'+QuotedStr(Artist4)+' and songlist.id not in ('+ListaIds+') order by rand() limit 0,2',[],True); Q.First; while not Q.EOF do begin Song2:=Q['filename']; if (Song4='') then Song4:=Q['filename']; Artist4:=Q['artist']; ListaIds:=ListaIds+','+IntToStr(Q['id']); Q.Next; end; Q.Free; //insiersco 4 canzoni causali e un jingle Queue.AddFile(Song1,ipBottom); Queue.AddFile(Song2,ipBottom); if(OrdineCategorie[looper]=17) then CAT['termoradio'].QueueBottom(smRandom, NoRules) else Queue.AddFile('C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\CONDIVISA\_jingle\auguri\Natale2001.mp3',ipBottom); Queue.AddFile(Song3,ipBottom); Queue.AddFile(Song4,ipBottom); end;