Skip to Content
It is currently May 27th, 2020, 10:28 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: February 26th, 2020, 10:08 am 
Offline
Senior User
Senior User

Joined: August 9th, 2003, 2:45 am
Posts: 100
Hello,
here is my script to change the track IDs on the player of the listeners
it should do:
Quote:
check if song is S
then replace artist and title name with a personal message
wait a few seconds
set back to the original artist and title tag
wait a few seconds
display another message
wait few seconds
display song artist and title tag
wait for 1 song and do it all again


the problem:
the songtype S check is not working, the PAL script is launched even if a jingle is played

Can you help me find the problem?

thank you
Tony

Code:
PAL.Loop := True;
var Q : TDataSet;
var Song : TSongInfo;
PAL.WaitForTime(T['+00:00:02']);
Song := ActivePlayer.GetSongInfo();
//_________________________________________//
IF Song['songtype'] = 'S' then
BEGIN
    Q := Queue.SongList;
    Q.First;
   
    {Change tag of the song}
    Song := TSongInfo.Create;
    Song['artist'] := 'message 1';
    Song['title'] := 'message 2';
    Encoders.SongChange(Song);
    Song.Free;
    PAL.WaitForTime(T['+00:00:15']);
END
ELSE
    Song.Free;
   
//_________________________________________//
if ActivePlayer <> nil then
    Encoders.SongChange(ActivePlayer.GetSongInfo);
Song.Free;
PAL.WaitForTime(T['+00:00:25']);
//_________________________________________//
Q := Queue.SongList;
Q.First;

Song := TSongInfo.Create;
Song['artist'] := 'message 3';
Song['title'] := 'message 4';
Encoders.SongChange(Song);
PAL.WaitForTime(T['+00:00:15']);
//_________________________________________//
if ActivePlayer <> nil then
    Encoders.SongChange(ActivePlayer.GetSongInfo);
Song.Free;

PAL.WaitForPlayCount(1);


Last edited by Mastacheata on February 28th, 2020, 5:37 am, edited 1 time in total.
indent code in CODE tag


Top
 Profile  
Reply with quote  
PostPosted: February 28th, 2020, 5:49 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7968
Location: Aachen (Germany)
What your script actually does:
Wait 2 seconds
if songtype is S
| Get the first item from queue and do nothing with it
| Display message1 - message2 as the current track title for about 17-18 seconds (15 seconds wait + 2 lines execution at 1 line per second) before going back to the actual track title

In any case display message 3 - message 4 as the current track title after about 30 seconds (either after the start of the script or after the other message) for about 17-18 seconds (15 seconds wait + 2 lines execution at 1 line per second) before going back to the actual track title

Wait for the current track to finish playing then repeat.


---

I'm not 100% sure if that's really what you wanted to happen as your code wasn't indented to show your intentions. Not sure if you maybe missed a begin and end on the else path of your first if...

_________________
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 29th, 2020, 9:03 am 
Offline
Senior User
Senior User

Joined: August 9th, 2003, 2:45 am
Posts: 100
Thank you for your answer, what i would like to do with this PAL script is:

each time a song "S" is inceted in a player, check if song is "S"
if YES
replace the artist and title tag with a personal message (message1/message2) for 15sec
THEN
put the original artst-tilte tag back for 25sec
THEN
replace the artist and title tag with a personal message (message3/message4) for 15sec
THEN
put the original artst-tilte tag back until the end of the song
THEN
wait for 1 song and do it all over again


Top
 Profile  
Reply with quote  
PostPosted: February 29th, 2020, 9:25 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7968
Location: Aachen (Germany)
So basically all your actions that are currently outside the IF block were supposed to go in the TRUTHY phase of the conditional?
Code:
PAL.Loop := True;
var Song : TSongInfo;
PAL.WaitForTime(T['+00:00:02']);
Song := ActivePlayer.GetSongInfo();
//_________________________________________//
IF Song['songtype'] = 'S' then
BEGIN
    {Change tag of the song}
    Song := TSongInfo.Create;
    Song['artist'] := 'message 1';
    Song['title'] := 'message 2';
    Encoders.SongChange(Song);
    PAL.WaitForTime(T['+00:00:15']);
    //_________________________________________//
    if ActivePlayer <> nil then
        Encoders.SongChange(ActivePlayer.GetSongInfo);
    Song.Free;
    PAL.WaitForTime(T['+00:00:25']);
    //_________________________________________//
    Song := TSongInfo.Create;
    Song['artist'] := 'message 3';
    Song['title'] := 'message 4';
    Encoders.SongChange(Song);
    PAL.WaitForTime(T['+00:00:15']);
    //_________________________________________//
    if ActivePlayer <> nil then
        Encoders.SongChange(ActivePlayer.GetSongInfo);
END;
Song.Free;
PAL.WaitForPlayCount(1);

_________________
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 29th, 2020, 10:02 am 
Offline
Senior User
Senior User

Joined: August 9th, 2003, 2:45 am
Posts: 100
Yes

Thank you very much for posting the script.

it's not working, it waits for 2 seconds, check if song is S then goes directly to the line:

Quote:
Encoders.SongChange(ActivePlayer.GetSongInfo);
at the end of the script
then it waits for 1 song to play


Top
 Profile  
Reply with quote  
PostPosted: February 29th, 2020, 2:33 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7968
Location: Aachen (Germany)
Have you recompiled the script after changing the code?
Also you might want to try stepping through the code using the "Run Line-by-Line" button to find out where it's got a problem.
The only thing broken I can see is the waiting stuff. Don't know why I missed that in the first place, but in PAL you cannot "wait" inside of IF statements.
To fix that you can replace the IF by a loop with only one iteration:

This:
Code:
IF Song['songtype'] = 'S' then

Becomes:
Code:
VAR skip : boolean = false;
while Song['songtype'] = 'S' and not skip DO


And before the loop ends:
Code:
END;


Turns into:
Code:
    skip := True;
END;

_________________
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  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 15 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