Skip to Content
It is currently July 6th, 2022, 8:36 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: January 24th, 2017, 5:34 am 
Offline
Junior User
Junior User

Joined: April 21st, 2013, 12:27 pm
Posts: 58
Hi.I have a problem with a script.It is supossed to play a random jingle on top before the requested song is playing.I want it to add for each requested song a jingle before it.

Code:
VAR req : TSongInfo;

PAL.Loop := True;
PAL.WaitForPlayCount(1);
PAL.LockExecution;

req := Queue.NextInQueue;
Queue.Add(req, ipTop);

 IF ( (req['requestID'] > 0) ) THEN
   CAT['Jingles (All)'].QueueTop(smRandom, NoRules);

Queue.Add(req, ipTop);

PAL.UnlockExecution;


Top
 Profile  
Reply with quote  
PostPosted: January 27th, 2017, 9:12 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8306
Location: Cologne (Germany)
You mention having A problem, but would you mind telling us WHAT the problem is?

Code:
req := Queue.NextInQueue;
Queue.Add(req, ipTop);

This section picks up the topmost track from the queue and readds it at the same position.
That looks fine so far.

Code:
IF ( (req['requestID'] > 0) ) THEN
  CAT['Jingles (All)'].QueueTop(smRandom, NoRules);

If the topmost queued track was requested, add a jingle right before it.

Code:
Queue.Add(req, ipTop);

This makes no sense at all.
After this command the first tracks in the queue look like this:
Code:
req (always here from step 3)
Jingle (only if req was a request from step 2)
req (always here from  step 1)



In the first step you pick the track from the queue (removing it) and readd it at the same position no matter what.
Next step is adding a Jingle in front, but only if said track from the first step was requested.
In the last step you add the track from step 1 to the top of the queue. (in front of the first add and in front of the jingle if that was added)

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: February 24th, 2021, 1:27 pm 
Offline
Junior User
Junior User

Joined: February 22nd, 2015, 3:22 pm
Posts: 32
I would really like the pal script that plays a jingle before playing a requested song.

But i tried it like shown below:

Code:
VAR req : TSongInfo;

PAL.Loop := True;
PAL.WaitForPlayCount(1);
PAL.LockExecution;

req := Queue.NextInQueue;
Queue.Add(req, ipTop);

 IF ( (req['requestID'] > 0) ) THEN
   CAT['Jingles (All)'].QueueTop(smRandom, NoRules);


It sets a jingle in front of a song with requested ID. But after the requested song it keeps playing jingles only.

What is exactly missing in this PAL script?

_________________
Your Music, Your Station!
Easy Listening, Love Songs, Romantic Hits, Soft Rock
https://radiolovetunes.com/


Top
 Profile  
Reply with quote  
PostPosted: February 24th, 2021, 1:44 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8306
Location: Cologne (Germany)
#1 You missed the unlockexection to your lockexecution.

#2 Needs a bit explanation:
Let's assume you have 3 tracks in queue and the next up is a requested (*) track.
Code:
A
B*
C


Your script begins, waits for the requested track to reach the top of the queue and removes that track.
Code:
B*
C


It then readds the track on top and then a Jingle on top of that. Your Queue now looks like this:
Code:
JINGLE
B*
C


We've reached the end of your script and it begins at the top again because you set it to loop.
Now it waits for 1 track to play (your jingle should start) and then checks the top of the queue if that is a requested track. Obviously since the Jingle just played your top-most track is the request again and your script will add another jingle. Repeat this to infinity.

A proper fix would require you to wait for one more track only if you added a jingle. To do that you need to convert the if to a loop with only one iteration, though. I'm too tired to explain that now.
Alternatives: Only check every second track if it's requested or not (change WaitForPlayCount(1) to WaitForPlayCount(2)), or add a delay after waiting for the next track to play (change PAL.WaitForPlayCount(1); to PAL.WaitForPlayCount(1); PAL.WaitForTime('+00:01:00'); )

The delay is probably better, as it will still catch most requests (unless a short track less than a minute long, like a Jingle or Station ID plays before it) and doesn't explicitly skip tracks.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: February 27th, 2021, 2:15 am 
Offline
Junior User
Junior User

Joined: February 22nd, 2015, 3:22 pm
Posts: 32
Thanks,

This one works fine!

Code:
VAR req :
TSongInfo;

PAL.Loop := True;
PAL.WaitForPlayCount(1); PAL.WaitForTime('+00:01:00');
PAL.LockExecution;

req := Queue.NextInQueue;
Queue.Add(req, ipTop);

 IF ( (req['requestID'] > 0) ) THEN
   CAT['Jingle Request'].QueueTop(smRandom, NoRules);

_________________
Your Music, Your Station!
Easy Listening, Love Songs, Romantic Hits, Soft Rock
https://radiolovetunes.com/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group