Automation warning script

Hi, one for Torben or Cad.

We need a script to run from a key command at the same time as we put mAirList into automated playout from a keystroke. (Obviously both functions will run from the same key).

Once in auto and playing a visual flash during automation of the player would be handy (similar to the one Cad recently wrote) only this time it needs to flash constantly until automation is turned off.

We do not use the control bar, so although presenters expect mAirList to be running in automationthey have no visual clue.

Kind regards tony

edit.Once automation is turned off we need to return to showing EOF during Assist. definitely a mod of an existing script by Cad.

Cad, this is what we have so far;

[code]// AutoFlash - a custom mAirList Notification Script

// Adapted from an original script by Cad Delworth CEng MBCS CITP,
// Clearances Manager, Leith FM, Edinburgh, Scotland
// http://www.leithfm.co.uk

// Each time Automation starts, this script changes the ‘flash on EOF warning’ time
// of Player 1 (single player automation).
// The time is changed to 180 seconds if one Item or fewer* remains in the Playlist;
// otherwise the time is set to zero.

// *NOTE that this script will OCCASIONALLY ‘flash’ the Players when it should not.
// This is because the Playlist count at Player Start includes the PREVIOUS Item.

procedure OnAutomationChange(PlayerControl: IPlayerControl; Item: IPlaylistItem);
var
bSetEofWarning: boolean;
i, iMax: integer;
i64FlashTime: int64;
pbc: IPlaybackControl;
plc: IPlayerControl;
begin
// Change the default (180) in the line below to change the flash time
i64FlashTime := 180 * 10000000;
pbc := CurrentPlaybackControl;
bSetEofWarning := pbc.GetAutomation;
if CurrentPlaylist.GetCount > 2 then
bSetEofWarning := true;
begin
iMax := pbc.GetPlayerCount - 1;
for i := 0 to iMax do
begin
plc := pbc.GetPlayer(i);
if bSetEofWarning = true then
plc.SetEofWarning(i64FlashTime)
else
plc.SetEofWarning(0);
end;
end;
end;

begin
end.[/code]

Almost identical to you code and works the same, note the use of OnAutomationChange and a true statement. However once we go back to automation we need to reset the EOF during Assist to our defaults.

Here is your original script:

[code]// AutoLastItemFlash - a custom mAirList Notification Script for Thornbury FM

// written by Cad Delworth CEng MBCS CITP,
// Clearances Manager, Leith FM, Edinburgh, Scotland
// http://www.leithfm.co.uk

// Each time a Player starts, this script changes the ‘flash on EOF warning’ time
// of all Players in the current Playlist.
// The time is changed to 60 seconds if one Item or fewer* remains in the Playlist;
// otherwise the time is set to zero.

// *NOTE that this script will OCCASIONALLY ‘flash’ the Players when it should not.
// This is because the Playlist count at Player Start includes the PREVIOUS Item.

procedure OnPlayerStart(PlayerControl: IPlayerControl; Item: IPlaylistItem);
var
bSetEofWarning: boolean;
i, iMax: integer;
i64FlashTime: int64;
pbc: IPlaybackControl;
plc: IPlayerControl;
begin
// Change the default (60) in the line below to change the flash time
i64FlashTime := 60 * 10000000;
pbc := CurrentPlaybackControl;
bSetEofWarning := pbc.GetAutomation;
if CurrentPlaylist.GetCount > 2 then
bSetEofWarning := false;
begin
iMax := pbc.GetPlayerCount - 1;
for i := 0 to iMax do
begin
plc := pbc.GetPlayer(i);
if bSetEofWarning = true then
plc.SetEofWarning(i64FlashTime)
else
plc.SetEofWarning(0);
end;
end;
end;

begin
end.[/code]

This is where I am stuck. Any ideas.

Kind regards tony

Hi Cad or Torben any ideas. So far we now have this:

[code]// AutoFlash - a custom mAirList Notification Script
// Adapted from an original script by Cad Delworth CEng MBCS CITP,
// Clearances Manager, Leith FM, Edinburgh, Scotland
// http://www.leithfm.co.uk

// Each time Automation changes to Assist, this script changes the ‘flash on EOF warning’ time
// of Player 1 (single player automation).
// The time is changed to 10 seconds if in Assist;
// otherwise the time is set to 180 seconds.

procedure OnAutomationChange(PlayerControl: IPlayerControl; Item: IPlaylistItem);
var
bSetEofWarning: boolean;
i, iMax: integer;
i64FlashTime: int64;
begin
// Change the default (10) in the line below to change the flash time

if (CurrentPlaybackControl.GetAutomation) = false then;
bSetEofWarning = 10 *10000000;
else
if (CurrentPlaybackControl.GetAutomation) = true then;
bSetEofWarning = 180 *1000000;

end;

end;
end;

begin
end.[/code]

It falls over at the first bSetEofWarning asking for an assignment.

Kind regards tony

Yes even at this time still working on this. Close now with this code:

[code]// AutoFlash - a custom mAirList Notification Script
// Adapted from an original script by Cad Delworth CEng MBCS CITP,
// Clearances Manager, Leith FM, Edinburgh, Scotland
// http://www.leithfm.co.uk

// Each time Automation changes to Assist, this script changes the ‘flash on EOF warning’ time
// of Player 1 (single player automation).
// The time is changed to 10 seconds if in Assist;
// otherwise the time is set to 180 seconds.

procedure OnAutomationChange(PlayerControl: IPlayerControl; Item: IPlaylistItem);
var
i64FlashTime: int64;

begin
// Change the default (180) in the line below to change the flash time
if (CurrentPlaybackControl.GetAutomation = false) then
i64FlashTime := 10 * 10000000;

begin

if (CurrentPlaybackControl.GetAutomation = true) then
i64FlashTime := 180 * 10000000;

end;

end;
begin
end.[/code]

It sets the flash time for EOF in assist (10 seconds).

Still will not set the flash time in Automation. No errors generated, what am I missing?

Kind regards Tony

edit:changed 180 *10000000 to 10000000 this needs to be constant during automation

Rather than use a notification script can we use the runscript command ?

(could even be 2 seperate runscript commands as auto On/Off are different keystrokes)

Glad to see you got rid of the ; at the end of the if … then statements. You also need to remove the stray begin between the two if statements. :wink:

Unfortunately, having decided the EOF warning time to use, you’re not actually setting the EOF warning time (that’s what PlayerObject.SetEofWarning does).

I haven’t tested this, but it should work:

// AutoFlash - a custom mAirList Notification Script 
// Adapted from an original script by Cad Delworth CEng MBCS CITP,
// Clearances Manager, Leith FM, Edinburgh, Scotland
// http://www.leithfm.co.uk

// Each time Automation changes to Assist, this script changes the 'flash on EOF warning' time
// of each Player in the current Playlist.
// The time is changed to 10 seconds if in Assist;
// otherwise the time is set to 3700 seconds (to allow for playout of pre-recorded one-hour shows).

procedure OnAutomationChange(PlayerControl: IPlayerControl; Item: IPlaylistItem);
var
  i, iMax: integer;
  i64FlashTime: int64;
  pbc: IPlaybackControl;
  plc: IPlayerControl;
begin
  pbc := CurrentPlaybackControl;
  bSetEofWarning := pbc.GetAutomation;
// Change the defaults (3700 and 10) in the statement below to change the flash times
  if pbc.GetAutomation = true then
    i64FlashTime := 3700 * 10000000
  else
    i64FlashTime := 10 * 10000000;
  iMax := pbc.GetPlayerCount - 1;
  for i := 0 to iMax do
  begin
    plc := pbc.GetPlayer(i);
    plc.SetEofWarning(i64FlashTime);
  end;
end;

begin
end.

I changed the ‘AUTO mode flash time’ so that you can play pre-records. I also put back the loop to set EOF time on all Players, so that you don’t need to change anything if you change to two or more Players in future. ;D

BFN
CAD

Hi Cad, thanks for your time. Looks like i was going in the wrong direction with this, taking all your statements out.

The one thing it did done was flash at EOF.

Just tried your recent script which falls over at line 19 on the error an unknown identifier bSetEofWarning.

I added the line:bSetEofWarning: boolean;

in the var.

Now the errors are gone but the script will still not flash in automation. What have else am I mistaken on, which thanks to your help is greatly reduced?

Kind regards tony

Hi, not exactly the solution we would like, as we wish to hide the control bar (Assist/Auto/Event). With the control bar enabled to show single buttons and to flash in auto, it does give a visual reminder as to what is happening, so will try this and hope everyone is happy.

Cad please take another look at the script in the meantime.

Kind regards tony

Hmm … that will teach me to test scripts before posting them! :-[

I’ll tow it away, lift the bonnet, and return it in an hour or two in a working condition. ;D

BFN
CAD

RIGHT! I’ve CRACKED IT! ;D

A little debugging time soon found a Big Potential Pitfall when using manifest constants (that’s: ‘numbers written in the code’ ;)) when the result needs to be int64 because a standard int just isn’t big enough to hold that number.

If you write (as I did):
SomeInt64Var := 3700 * 10000000;
mAirListScript (well, PascalScript really!) ignores the int64 on the left and calculates the multiplication using int and thus unintentionally, your result becomes roughly -1700000000 instead of 37000000000.

The way to fix this is to write instead:
Int64Var1 := 10000000;
SomeInt64Var := 3700 * Int64Var1;
A little programming trick :wink: to force PascalScript to do the multiplication as int64. 8)

I admit there was another bug (the BooleanVar := GetAutomation statement was redundant), so the finished, working, and above all TESTED :smiley: code is:

// AutoFlash - a custom mAirList Notification Script 
// Adapted from an original script by Cad Delworth CEng MBCS CITP,
// Clearances Manager, Leith FM, Edinburgh, Scotland
// http://www.leithfm.co.uk

// Each time Automation changes, this script changes the 'flash on EOF warning' time
// of each Player in the current Playlist.
// The time is changed to 10 seconds if in Assist;
// in Auto, the time is set to 3700 seconds (to allow for pre-recorded one-hour shows).

procedure OnAutomationChange(PlayerControl: IPlayerControl; Item: IPlaylistItem);
var
  i, iMax: integer;
  i64FlashTime, i64OneSecond: int64;
  pbc: IPlaybackControl;
  plc: IPlayerControl;
begin
  pbc := CurrentPlaybackControl;
  i64OneSecond := 10000000;
// Change the defaults (3700 and 10) in the IF statement below to change the flash times
  if pbc.GetAutomation = true then
    i64FlashTime := i64OneSecond * 3700
  else
    i64FlashTime := i64OneSecond * 10;
  iMax := pbc.GetPlayerCount - 1;
  for i := 0 to iMax do
  begin
    plc := pbc.GetPlayer(i);
    plc.SetEofWarning(i64FlashTime);
  end;
end;

begin
end.

A fun bug to find (and work around!).

PS: It also seems that IntToStr has the same ‘uses int internally’ problem, though I haven’t checked whether or not an Int64ToStr function exists or not. If not, Torben: that would be a terrific addition to assist when mAirListScript debugging, given how many data items in mAirList are stored as int64.

PPS to Tony: You’ll find this new, working version will switch the flashing on/off literally when you click the button OR press the keyboard key, even if a Player is playing. Looks quite groovy seeing it do that, actually!

BFN
CAD

Cheers Cad, works a treat.

Now to wait and hear the users comments.

Thanks again.

Kind Regards Tony

The multiplication thing is rather a Pascal Script issue than a Delphi one. If I find the time, I can try to debug it and file a bug report (it might also be fixed in the current versions - mAirList still uses a rather old one). Your workaround seems to work fine though.

IntToStr is an overloaded function in Delphi:

function IntToStr(Value: Integer): string; overload;
function IntToStr(Value: Int64): string; overload;

From what I know, Pascal Script cannot handle overloaded function but can only offer one alternative. Seems like it’s the first one - which is a pity, because the int64 version would also be able to handle 32bit values, of course.

I can work around this by introducing an explicit Int64ToStr function, as requested.