just after a bit of help please, ive just discovered charlies awesome mAirlist clock and am trying to get it to work… Im not brilliant with scripting as im sure you’ll know!
i have tried adding all of the script required into one script and telling it mairlist where it is etc, that didnt work so i tried breaking it up into the individual sections for example the NOW PLAYING part, it also threw that back with the following error:
Have a look at the Notification Script Template, the parameter lists of all the OnPlayerStart etc. functions have changed in v3.0.
For example, OnPlayerStart now passes the number of the playlist (0-based) and the number of the player (also 0-based), and you can acess the item like this:
PS, please use the “code” environment in the forum editor, it will make your scripts more readable. (It can be accessed by clicking the small button labeled “#” in the editor toolbar.)
I’ve been following this thread but I can’t find the ‘inspiration’ for it! Could Lackster please post a link to the ‘awesome mAirList clock’ so I know what he’s referring to?
The final “begin end.”, with a period, is the main program which happens to be empty as mAirList calls the individual procedures of a notfication script directly. In an ordinary script, you would put the main code between “begin” and “end.”, but you can still put some of your code into procedures which you call from your main program.
That worked and using what i’ve learnt so far i managed to get others to work also! Thanks for your time…
I do have one more cheeky request though, what needs to be done to the following to get them to work as im getting the error:
(4:1)/(3:1/(3:1) ‘identifier expected’
procedure OnPlayerStop(PlayerControl: IPlayerControl; Item: IPlaylistItem; Duration: int64);
var
var sl: TStringList;
begin
sl := TStringList.Create;
sl.Add('[EOM]');
sl.Add('Status=0');
sl.SaveToFile('C:\Program Files\mAirList\EOMSTATUS.txt');
sl.Free;
end;
begin
end.
[code]procedure OnOnAir;
var
var sl: TStringList;
begin
sl := TStringList.Create;
sl.Add(’[OnAir]’);
sl.Add(‘Status=1’);
sl.SaveToFile(‘C:\Program Files\mAirList\ONAIRSTATUS.txt’);
sl.Free;
end;
begin
end;[/code]
[code]procedure OnOffAir;
var
var sl: TStringList;
begin
sl := TStringList.Create;
sl.Add(’[OnAir]’);
sl.Add(‘Status=0’);
sl.SaveToFile(‘C:\Program Files\mAirList\ONAIRSTATUS.txt’);
sl.Free;
end;
begin
end;[/code]
If you’d be able to help me out with that request it would be awesome…
Just finally, with the clock, it has the traffic flag, i dont have systems etc that cut in with RDS etc etc, but i would like to get it to work, could you suggest the best way to get that to work?
i was thinking along the lines of tagging a particular audio file that on ITEM START it runs a script and on ITEM STOP runs a script that switches the traffic flag light on and off.
Easy: in each script, remove the line which reads var (with nothing after it). The error message you’re seeing translates as ‘You’ve put in a var but you haven’t put any variable declarations after it.’
The purpose of var is to declare variables which the program code following the var will use. You should not have more than one var line per procedure or function, but you can follow it by as many variable declaration lines as you want or need, ending each declaration line with a semicolon [;]. For example:
var
varname1: vartype1;
varname2: vartype2;
...
begin
program statement;
...
end;
The var ‘section’ is implicitly ended by the begin statement. There is no ‘endvar’ or anything like it.
You can combine the var and the first variable declaration into a single line, so this will work:
var varname1: vartype1;
begin
program statement;
...
end;
… but if you had more than one variable, you would (properly) put var on a line by itself; that makes the var much easier to find (and read) later!
Thank you all for your help - im pleased to report that it is all running as it should now!
my final, i promise, request for now is about a script which would turn the traffic flag on when a particular audio file is played and off when that audio file is stopped would be great!
begin
sl := TStringList.Create;
sl.Add(’[TRAFFICFLAG]’);
sl.Add(‘Status=1’);
sl.SaveToFile(‘C:\Program Files\mAirList\TRAFFICFLAG.txt’);
end;
begin
end.
[/code]
Like i say, i assume that is what it should look roughly like, that doesnt work though… I hope it gives enough to work from, if not let me know and i’ll provide more info for you.
Basically it needs to change a property field from 0 to 1 when a file begins and then i need one that turns the 1 back to a 0 when the file is stopped. i just dont know the correct coding to put in to make it relevant to 1 particular piece of audio.
(By the way, bold and italic doesn’t work inside ‘code’ tags.)
1: You have to put the var block/statement after the procedure statement, not before it.
2: You need to check the Title (I assume it’s the title you want to check, yes?) of the item which has just started, like so:
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer);
var
sl: TStringList;
MyItem: IPlaylistItem;
begin
MyItem := Playlist(PlaylistIndex).GetPlayer(PlayerIndex).GetItem;
if MyItem.GetTitle = 'Traffic Bed' then
begin
sl := TStringList.Create;
sl.Add('TRAFFICFLAG');
sl.Add('Status=1');
sl.SaveToFile('C:\Program Files\mAirList\TRAFFICFLAG.txt');
end;
end;
begin
end.
But there is a better way. Write two scripts: one which sets the Traffic Flag ON, and one which sets the Traffic Flag OFF. Then all you need to do is to change the Properties of the traffic bed (or whatever audio item you choose) to add an Action on Start to run the ‘set flag’ script, and an Action on Stop to run the ‘un-set flag’ script. Then the traffic bed (or whatever audio item it is) will run the correct scripts EVERY time it starts and stops, without needing any notification scripts.
Note that these two scripts would be stand-alone scripts, so they would look like this:
// Set traffic flag ON
var
sl: TStringList;
begin
sl := TStringList.Create;
sl.Add('TRAFFICFLAG');
sl.Add('Status=1');
sl.SaveToFile('C:\Program Files\mAirList\TRAFFICFLAG.txt');
end.
If it’s only a few items which should trigger the script (i.e. the traffic jingles), I would also recommend to use it as a standalone script which is called from the Actions on Start (or Actions on Stop, respectively) of that particular items.