Hello. I'm trying to make a script that will play a jingle ebfore playing any other track.
Code:
/ Playlist script by DarthManâ„¢
// define current/next song, active player variables
var iCurrentSong, iNextSong : TSongInfo;
var iActivePlayer : TPlayer;
var bPlayListGenerated : Boolean = False;
// continuous loop
pal.loop := True;
// lock pal execution
Pal.LockExecution;
iActivePlayer := ActivePlayer;
iCurrentSong := iActivePlayer.GetSongInfo;
iNextSong := Queue.NextInQueue;
Queue.Add(iNextSong, ipTop);
// if current song is not null and is type song, not jingle etc and there is no next track
if iCurrentSong <> nil then
begin
if ((iCurrentSong['songtype'] = 'S') and (iNextSong = nil)) then
begin
Cat['Jingles (All)'].QueueBottom(smRandom, NoRules);
Cat['Underground'].QueueBottom(smPriority, EnforceRules);
end;
end
else
begin
Cat['Underground'].QueueBottom(smPriority, EnforceRules);
end;
bPlayListGenerated := ((iCurrentSong <> nil) and (iNextSong <> nil));
//unlock pal execution
Pal.unLockExecution;
//free the variables if the playlist was generated
if bPlayListGenerated = True then
begin
iCurrentSong.Free;
iNextSong.Free;
iActivePlayer.Free;
end;
//wait for count
Pal.WaitForPlayCount(1); //Restart after 1 play
What could be wrong?
It works, then 2nd time it doesn,t 3rd time it works again etc.