Mairlist Clock script

Hi Guys,

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:

Error Loading (filename) [error] (3:1) Unknown identifier ‘sl’

Any ideas? i am using an up to date v3 mairlist.

The scripts i need to get to work are:

var sl: TStringList;

procedure OnOnAir;
begin
sl := TStringList.Create;
sl.Add(’[OnAir]’);
sl.Add(‘Status=1’);
sl.SaveToFile(‘S:\ONAIRSTATUS.txt’);
sl.Free;
end;

procedure OnOffAir;
begin
sl := TStringList.Create;
sl.Add(’[OnAir]’);
sl.Add(‘Status=0’);
sl.SaveToFile(‘S:\ONAIRSTATUS.txt’);
sl.Free;
end;

procedure OnCartPlayerStop(PlayerControl: IPlayerControl; Item: IPlaylistItem; Duration: int64);
begin
sl := TStringList.Create;
sl.Add(’[EOM]’);
sl.Add(‘Status=0’);
sl.SaveToFile(‘C:\mAirList\EOMSTATUS.txt’);
sl.Free;
end;

procedure OnCartPlayerEOFWarning(PlayerControl: IPlayerControl; Item: IPlaylistItem);
begin
sl := TStringList.Create;
sl.Add(’[EOM]’);
sl.Add(‘Status=1’);
sl.SaveToFile(‘C:\mAirList\EOMSTATUS.txt’);
sl.Free;
end;

procedure OnPlayerStop(PlayerControl: IPlayerControl; Item: IPlaylistItem; Duration: int64);
begin
sl := TStringList.Create;
sl.Add(’[EOM]’);
sl.Add(‘Status=0’);
sl.SaveToFile(‘C:\mAirList\EOMSTATUS.txt’);
sl.Free;
end;

procedure OnPlayerEOFWarning(PlayerControl: IPlayerControl; Item: IPlaylistItem);
begin
sl := TStringList.Create;
sl.Add(’[EOM]’);
sl.Add(‘Status=1’);
sl.SaveToFile(‘C:\mAirList\EOMSTATUS.txt’);
sl.Free;
end;

sl := TStringList.Create;
sl.Add(Item.GetArtist + ’ - ’ + Item.GetTitle);
sl.SaveToFile(‘C:\mAirList\currentsong.txt’);
sl.Free;

Many Thanks

through continuing to ‘fiddle’ i have realised a left a line out which is why i was getting the

‘sl’ error…

However, i now get an error when i just try the NOW PLAYING part…

sl := TStringList.Create;
sl.Add(Item.GetArtist + ’ - ’ + Item.GetTitle);
sl.SaveToFile(‘C:\mAirList\currentsong.txt’);
sl.Free;

For some reason it doesnt understand the ‘Item’ part of the script which is why it isnt working with that… any ideas?

thanks

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:

procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer);
var
  item: IPlaylistItem;
begin
  item := Playlist(PlaylistIndex).GetPlayerControl(PlayerIndex).GetItem;

  sl := TStringList.Create;
  sl.Add(Item.GetArtist + ' - ' + Item.GetTitle);
  sl.SaveToFile('C:\mAirList\currentsong.txt');
  sl.Free;
end;

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.)

Just about following torben…

i just tried the script you’ve adjusted for me and i now get the following:

Error loading C:\Program Files\mAirList\NOW PLAYING SCRIPT.mls: [Error] (5:35): Unknown identifier ‘GETPLAYERCONTROL’

Any ideas?

Thanks

Oh, sorry, it’s GetPlayer.

Hi torben,

sorry to drag this out, i simply dont understand scripts!

The error now is [error] (7:3) unknown identifier ‘sl’

Thanks

I think you forgot the first line from your original script:

var sl: TStringList;

so the script should be:

[code]procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer);
var
item: IPlaylistItem;
var sl: TStringList;

begin
item := Playlist(PlaylistIndex).GetPlayer(PlayerIndex).GetItem;

sl := TStringList.Create;
sl.Add(Item.GetArtist + ’ - ’ + Item.GetTitle);
sl.SaveToFile(‘C:\mAirList\currentsong.txt’);
sl.Free;
end;
[/code]

If this is supposed to be self-contained notification script, then there’s the obligatory

begin
end.

missing at the end of the file.

I do believe we are getting there now!

Just tried again this morning and the error i get now is:

[Error] (10:15): Unknown identifier ‘GETARTIST’

Any thoughts?

Many Thanks

Ah, that’s because mAirList 3 supports more than one artist per track.

Use GetArtistsString instead, it will return the list of all artists join by a “/” sign.

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?

Thanks in advance.

BFN
CAD

Hi guys.

i really think we are getting somewhere now as the error im getting now is to do with the end of the file, so i assume the rest is ok now! HURRAH!?

This is the error i now get…

Error loading C:\Program Files\mAirList\NOW PLAYING SCRIPT.mls: [Error] (15:1): Unexpected end of file

The script now looks like:

[code]procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer);
var
item: IPlaylistItem;
var sl: TStringList;

begin
item := Playlist(PlaylistIndex).GetPlayer(PlayerIndex).GetItem;

sl := TStringList.Create;
sl.Add(Item.GetArtistsString + ’ - ’ + Item.GetTitle);
sl.SaveToFile(‘C:\mAirList\currentsong.txt’);
sl.Free;
begin;
end;
[/code]

I wasnt sure if the begin was supposed to be above the end, so i tried without and then the error change to be:

Error loading C:\Program Files\mAirList\NOW PLAYING SCRIPT.mls: [Error] (14:1): Unexpected end of file

Hope that helps.

Thank You

Hi Cad

Here is the link to get the mairlist clock…

I hope charlie doesn’t mind me posting a link to his website - http://www.charliedavy.co.uk/software.php#mAirListClock

Thanks

[code]procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer);
var
item: IPlaylistItem;
var sl: TStringList;

begin
item := Playlist(PlaylistIndex).GetPlayer(PlayerIndex).GetItem;

sl := TStringList.Create;
sl.Add(Item.GetArtistsString + ’ - ’ + Item.GetTitle);
sl.SaveToFile(‘C:\mAirList\currentsong.txt’);
sl.Free;
end;

begin
end.[/code]

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.

Wahey!

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.

Any thoughts/help would be gratefully received.

Lackster

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! :wink:

Hope that helps!

BFN
CAD

You guys are great!

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!

here is what i assume it would need to be like:

[code]var sl: TStringList;

procedure OnPlayer/ItemStart(PlaylistIndex: integer; PlayerIndex: integer);

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.

Many Thanks

(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.

(The line starting // is a comment.)

BFN
CAD

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.